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

Chore: Add a script for testing with more control #12444

Merged
merged 2 commits into from Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/developer-guide/unit-tests.md
Expand Up @@ -12,6 +12,10 @@ This automatically starts Mocha and runs all tests in the `tests` directory. You

If you want to quickly run just one test, you can do so by running Mocha directly and passing in the filename. For example:

./node_modules/.bin/mocha tests/lib/rules/no-wrap-func.js
npm test:cli tests/lib/rules/no-wrap-func.js

Running individual tests is useful when you're working on a specific bug and iterating on the solution. You should be sure to run `npm test` before submitting a pull request.

## More Control on Unit Testing

`npm test:cli` is an alias of the Mocha cli in `./node_modules/.bin/mocha`. [Options](https://mochajs.org/#command-line-usage) are available to be provided to help to better control the test to run.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -9,6 +9,7 @@
"main": "./lib/api.js",
"scripts": {
"test": "node Makefile.js test",
"test:cli": "./node_modules/.bin/mocha",
Copy link
Member

Choose a reason for hiding this comment

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

Would it work to simply say "mocha" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It takes me quite a while to think about the naming and I can't think of a good one.🤦‍♂️
Maybe mocha works better.

Copy link
Member

Choose a reason for hiding this comment

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

Ack, I apologize, I wasn't clear.

I meant to say that you shouldn't need to prefix the mocha command:

"test:cli": "mocha"

This is because npm scripts should have the ./node_modules/.bin added to the path environment variable.

I like the script name test:cli. It's generic, and we wouldn't need to change it if we moved away from mocha.

"lint": "node Makefile.js lint",
"fix": "node Makefile.js lint -- fix",
"fuzz": "node Makefile.js fuzz",
Expand Down