]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/developer-guide/unit-tests.md
281c39674540e5eb2f815f81f706934b7bf338da
[pve-eslint.git] / eslint / docs / developer-guide / unit-tests.md
1 # Unit Tests
2
3 Most parts of ESLint have unit tests associated with them. Unit tests are written using [Mocha](https://mochajs.org/) and are required when making contributions to ESLint. You'll find all of the unit tests in the `tests` directory.
4
5 When you first get the source code, you need to run `npm install` once initially to set ESLint for development. Once you've done that, you can run the tests via:
6
7 npm test
8
9 This automatically starts Mocha and runs all tests in the `tests` directory. You need only add yours and it will automatically be picked up when running tests.
10
11 ## Running Individual Tests
12
13 If you want to quickly run just one test, you can do so by running Mocha directly and passing in the filename. For example:
14
15 npm run test:cli tests/lib/rules/no-wrap-func.js
16
17 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.
18
19 ## More Control on Unit Testing
20
21 `npm run 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.