Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated detection of Node and Japa test runners #96

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

fabnguess
Copy link
Contributor

This PR aims to improve the detection of test runners used in projects, particularly for Node.js and Japa.

Currently the code only checks the test script in the package.json file. However, in many projects it is the test-only script that is responsible for running the tests. This prevents correct detection of Node's test runner.

Proposed changes:
Test-only script support: The code has been changed to also check the test-only script in the package.json file, in addition to the test script.

Japa verification: As per Japa documentation, the presence of @japa/runner in devDependencies is now checked to identify projects using Japa as a test runner.

@PierreDemailly
Copy link
Member

I think we can go further by checking if the test script contains another script instead of looking for test-only specifically.
For instance, we can imagine something like this:
"test": "npm run test:ut && npm run test:ft"
And many other patterns.

In this example, we can detect that test:ut and test:ft are used in the test script, so we'll check both of them, recursively (if test:ut contains another script then we'll check it, etc).

Another way would be checking all scripts that contains (or starts with) test, so if we keep the first example, we'll detect that both test:ut and test:ft contains or starts with test then we'll check these scripts.
This way is probably simpler, WDYT?

@fabnguess
Copy link
Contributor Author

fabnguess commented Jan 11, 2025

I @PierreDemailly, The second approach seems easier to implement, while the first one offers greater flexibility. So, which solution would you prefer us to focus on?

@PierreDemailly

This comment was marked as off-topic.

@fabnguess
Copy link
Contributor Author

Well rated

@PierreDemailly
Copy link
Member

@fabnguess Nevermind i'm dumb 🤣
We detect these runners by checking if they are present in (dev) deps, script does not matter.

src/utils/getTestFrameworkName.ts Outdated Show resolved Hide resolved
src/utils/getTestFrameworkName.ts Outdated Show resolved Hide resolved
@fabnguess fabnguess force-pushed the update-test-framework-detection branch from ea6a43c to 85d71ad Compare January 11, 2025 23:37
@fabnguess fabnguess force-pushed the update-test-framework-detection branch from 85d71ad to 7884d0f Compare January 12, 2025 00:01
src/utils/getTestFrameworkName.ts Outdated Show resolved Hide resolved
@fabnguess fabnguess force-pushed the update-test-framework-detection branch from 7884d0f to c8a85d2 Compare January 12, 2025 12:56
@fabnguess fabnguess force-pushed the update-test-framework-detection branch from c8a85d2 to 4bafc42 Compare January 12, 2025 13:26
@fabnguess fabnguess force-pushed the update-test-framework-detection branch from 4bafc42 to eb88752 Compare January 12, 2025 13:30
@fraxken fraxken merged commit c553307 into main Jan 16, 2025
3 checks passed
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.

3 participants