refactor: use suite/test for hierarchical test structure#59
refactor: use suite/test for hierarchical test structure#59kraenhansen wants to merge 1 commit intomainfrom
Conversation
Replace flat test() calls with suite/test nesting so test output shows the directory hierarchy while still supporting --test-name-pattern filtering at any level (suite or leaf test). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
As #50 is merged, do we still need this? |
|
Short answer: Yes. This is an alternative suggestion that I'd like to propose (even with #50 merged) - the description above outlines two reasons I think this is better than the current state of the harness. |
I don't have a strong opinion about this. It would be interesting to see @legendecas perspective. |
|
|
||
| ```bash | ||
| $ NODE_OPTIONS=--test-name-pattern=js-native-api/test_constructor/test_null npm run node:test | ||
| $ NODE_OPTIONS=--test-name-pattern=test_constructor npm run node:test |
There was a problem hiding this comment.
There are test files with the same name in different folders, like js-native-api/2_function_arguments/test and js-native-api/3_callbacks/test. I think it is still helpful to be able to filter tests with a path.
This is mainly an alternative suggestion to #50 - feel free to close.
Summary
test()calls (from feat: flattern tests allowing --test-name-pattern filter #50) withsuite()/test()nesting, restoring hierarchical test output while keeping--test-name-patternfiltering support--test-name-patternmatches against both suite names (directories) and test names (files), so filtering works at any level of the hierarchyMotivation
PR #50 flattened all tests into top-level
test()calls with path-like names (e.g.js-native-api/test_string/test.js) to enable--test-name-patternfiltering. This works but comes with trade-offs:test_stringtests took combined), which is lost when tests are flatUsing
suite()/test()nesting preserves all of these while still supporting--test-name-pattern— the Node.js test runner matches the pattern against suite names too, running all tests inside a matching suite.Test plan
npm run node:testpasses (all tests run with hierarchical output)NODE_OPTIONS=--test-name-pattern=test_constructor npm run node:testcorrectly filters to only tests in thetest_constructorsuiteNODE_OPTIONS=--test-name-pattern=test_null npm run node:testcorrectly filters leaf tests across suites🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com