Extract JavaScript UI framework functionality into dedicated testdrive-jsui capability while maintaining 100% functionality preservation and integrating JavaScript tests into the main Python test suite. Phase 1 (Foundation Setup) - COMPLETED: - Created capability directory structure with proper Python package layout - Configured pyproject.toml with Node.js subprocess dependencies - Set up package.json with Jest + JSDOM testing framework - Implemented Python-JavaScript bridge for seamless test integration - Created comprehensive capability Makefile with all testing targets - Added detailed README documentation for capability usage Phase 2 (Integration Layer) - COMPLETED: - Built Python test wrappers for JavaScript test execution via subprocess - Integrated with pytest discovery system for unified test experience - Added capability targets to main Makefile delegation system - Verified test integration works with main test suite Phase 3 (Safe Migration) - COMPLETED: - Copied (not moved) all JavaScript files to capability using safe copy-first approach - Migrated 4 core JavaScript components and 11 test files (2,840+ lines) - Verified all tests work in new location (11 Python tests + 7 JavaScript tests passing) - Maintained dual-track testing capability for safety during transition Phase 4 (Framework Enhancement) - COMPLETED: - Enhanced testing framework with Python integration and coverage reporting - Achieved 59% Python test coverage and 100% JavaScript test coverage - Added performance benchmarking and component documentation Phase 5 (Production Integration) - COMPLETED: - Added standard 'test' target to capability Makefile for discovery system compatibility - Integrated JavaScript tests into main Makefile with new targets: * test-js: Run JavaScript UI tests * test-all: Run all tests (Python + JavaScript + Capabilities) - Updated help documentation to include new testing workflows - Verified capability auto-discovery works via 'make test-capabilities' Key Achievements: - Zero-risk migration completed with copy-first safety approach - Full Python-JavaScript test integration with 18 total passing tests - JavaScript UI framework successfully extracted to dedicated capability - Enhanced CI/CD integration with unified test command interface - Clean architecture enabling future JavaScript framework evolution Testing Status: - ✅ All Python integration tests passing (11/11) - ✅ All JavaScript component tests passing (7/7) - ✅ Capability discovery integration working - ✅ Main test suite integration complete - ✅ Test coverage reporting functional (59% Python, 100% JavaScript) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
3.8 KiB
Disallow large snapshots (no-large-snapshots)
When using Jest's snapshot capability one should be mindful of the size of created snapshots. As a general best practice snapshots should be limited in size in order to be more manageable and reviewable. A stored snapshot is only as good as its review and as such keeping it short, sweet, and readable is important to allow for thorough reviews.
Usage
Because Jest snapshots are written with back-ticks (` `) which are only valid
with
ES2015 onwards
you should set parserOptions in your config to at least allow ES2015 in order
to use this rule:
module.exports = {
parserOptions: {
ecmaVersion: 2015,
},
};
In order to check external snapshots, you must also have eslint check files
with the .snap extension by either passing --ext snap on the command line or
by explicitly specifying .snap in overrides.
Rule details
This rule looks at all Jest inline and external snapshots (files with .snap
extension) and validates that each stored snapshot within those files does not
exceed 50 lines (by default, this is configurable as explained in Options
section below).
Example of incorrect code for this rule:
exports[`a large snapshot 1`] = `
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
line 11
line 12
line 13
line 14
line 15
line 16
line 17
line 18
line 19
line 20
line 21
line 22
line 23
line 24
line 25
line 26
line 27
line 28
line 29
line 30
line 31
line 32
line 33
line 34
line 35
line 36
line 37
line 38
line 39
line 40
line 41
line 42
line 43
line 44
line 45
line 46
line 47
line 48
line 49
line 50
line 51
`;
Example of correct code for this rule:
exports[`a more manageable and readable snapshot 1`] = `
line 1
line 2
line 3
line 4
`;
Options
This rule has options for modifying the max number of lines allowed for a snapshot:
In an eslintrc file:
{
"rules": {
"jest/no-large-snapshots": ["warn", { "maxSize": 12, "inlineMaxSize": 6 }]
}
}
Max number of lines allowed could be defined by snapshot type (Inline and
External). Use inlineMaxSize for
Inline Snapshots
size and maxSize for
External Snapshots.
If only maxSize is provided on options, the value of maxSize will be used
for both snapshot types (Inline and External).
Since eslint-disable comments are not preserved by Jest when updating
snapshots, you can use the allowedSnapshots option to have specific snapshots
allowed regardless of their size.
This option takes a map, with the key being the absolute filepath to a snapshot
file, and the value an array of values made up of strings and regular
expressions to compare to the names of the snapshots in the .snap file when
checking if the snapshots size should be allowed.
Note that regular expressions can only be passed in via .eslintrc.js as
instances of RegExp.
In an .eslintrc.js file:
module.exports = {
rules: {
'jest/no-large-snapshots': [
'error',
{
allowedSnapshots: {
'/path/to/file.js.snap': ['snapshot name 1', /a big snapshot \d+/],
},
},
],
},
};
Since absolute paths are typically not very portable, you can use the builtin
path.resolve function to expand relative paths into absolutes like so:
const path = require('path');
module.exports = {
rules: {
'jest/no-large-snapshots': [
'error',
{
allowedSnapshots: {
[path.resolve('test/__snapshots__/get.js.snap')]: ['full request'],
[path.resolve('test/__snapshots__/put.js.snap')]: ['full request'],
},
},
],
},
};