parser: recognize Mocha TDD suite() as a test runner#423
Open
Pr1ncePS2002 wants to merge 1 commit intotirth8205:mainfrom
Open
parser: recognize Mocha TDD suite() as a test runner#423Pr1ncePS2002 wants to merge 1 commit intotirth8205:mainfrom
Pr1ncePS2002 wants to merge 1 commit intotirth8205:mainfrom
Conversation
The TDD interface in Mocha (`mocha --ui tdd`) uses `suite()` as the describe-equivalent. `test()`, the it-equivalent, was already in _TEST_RUNNER_NAMES; `suite()` was not, so a *.test.ts file using the TDD style produced no Test nodes for its top-level groupings. Add `suite` to _TEST_RUNNER_NAMES. Detection still requires the file to match a test-file pattern, so a stray `suite` call in production code is unaffected.
There was a problem hiding this comment.
Pull request overview
This PR extends the parser’s JavaScript/TypeScript test detection so Mocha’s TDD-style suite() blocks are recognized as test containers, bringing Mocha TDD support in line with the existing describe()/test() handling used for other JS test frameworks.
Changes:
- Added
"suite"to the parser’s recognized JS/TS test-runner call names. - Added a Mocha TDD fixture using
suite()andtest(). - Added a regression test verifying
suite()-based files produceTestnodes andTESTED_BYedges.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
code_review_graph/parser.py |
Expands JS/TS test-runner name detection to include Mocha TDD suite(). |
tests/fixtures/sample_mocha.test.ts |
Adds a representative Mocha TDD fixture for parser coverage. |
tests/test_parser.py |
Adds a regression test covering suite() recognition and resulting graph edges. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
suiteto_TEST_RUNNER_NAMESso files using Mocha's TDD interface (mocha --ui tdd) produceTestnodes for their top-level groupings.test()(theit-equivalent) was already recognized;suite()(thedescribe-equivalent) was not, leaving Mocha TDD codebases partially supported.What changed
code_review_graph/parser.py: add"suite"to_TEST_RUNNER_NAMEStests/fixtures/sample_mocha.test.ts: new fixture usingsuite()+test()tests/test_parser.py: regression testtest_mocha_tdd_suite_produces_test_nodesRisk
Low. Detection still requires the file to match a test-file pattern (
_is_test_file(file_path) and name in _TEST_RUNNER_NAMES), so a straysuite()call in production code is unaffected. Only added one name — deliberately did not addsetup/teardownbecause those names are too generic and could false-positive on helper functions inside test files.Test plan
uv run pytest tests/test_parser.py -k mocha -v— passinguv run pytest tests/test_parser.py -k vitest -v— adjacent describe()/it() detection unchanged (4/4)mainbaseline