Skip to content

parser: recognize Mocha TDD suite() as a test runner#423

Open
Pr1ncePS2002 wants to merge 1 commit intotirth8205:mainfrom
Pr1ncePS2002:feature/mocha-tdd-suite
Open

parser: recognize Mocha TDD suite() as a test runner#423
Pr1ncePS2002 wants to merge 1 commit intotirth8205:mainfrom
Pr1ncePS2002:feature/mocha-tdd-suite

Conversation

@Pr1ncePS2002
Copy link
Copy Markdown

Summary

Adds suite to _TEST_RUNNER_NAMES so files using Mocha's TDD interface (mocha --ui tdd) produce Test nodes for their top-level groupings. test() (the it-equivalent) was already recognized; suite() (the describe-equivalent) was not, leaving Mocha TDD codebases partially supported.

What changed

  • code_review_graph/parser.py: add "suite" to _TEST_RUNNER_NAMES
  • tests/fixtures/sample_mocha.test.ts: new fixture using suite() + test()
  • tests/test_parser.py: regression test test_mocha_tdd_suite_produces_test_nodes

Risk

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 stray suite() call in production code is unaffected. Only added one name — deliberately did not add setup/teardown because 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 — passing
  • uv run pytest tests/test_parser.py -k vitest -v — adjacent describe()/it() detection unchanged (4/4)
  • No new failures vs. main baseline

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.
Copilot AI review requested due to automatic review settings May 3, 2026 10:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and test().
  • Added a regression test verifying suite()-based files produce Test nodes and TESTED_BY edges.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants