https://github.com/javascript-studio/related-tests
🎓 Run related tests with lint-staged
https://github.com/javascript-studio/related-tests
Last synced: 6 months ago
JSON representation
🎓 Run related tests with lint-staged
- Host: GitHub
- URL: https://github.com/javascript-studio/related-tests
- Owner: javascript-studio
- License: mit
- Created: 2021-01-26T20:24:02.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-05T09:48:25.000Z (over 4 years ago)
- Last Synced: 2025-06-18T19:49:20.221Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 245 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# Studio Related Tests
🎓 Run related tests with `lint-staged`.
> Runs a command with all tests for staged files named `${filename}.test.js`,
> `${filename}-test.js`, `${filename}_anything.test.js`,
> `${filename}-anything.test.js` or `${filename}.anything.test.js`.
## Setup
This assumes you have [husky][] and [lint-staged][] installed.
```bash
npm i @studio/related-tests -D
```
**lint-staged.config.js**
```js
const withRelatedTests = require('@studio/related-tests');
module.exports = {
'*.js': withRelatedTests('mocha')
};
```
## Tip
To run the same test command, configure a `test:files` script and call
`withRelatedTests('npm run test:files')`:
```json
{
"scripts": {
"test": "npm run test:files -- './{,!(node_modules)/**}/*.test.js'",
"test:files": "mocha --require test/hooks.js"
}
}
```
[husky]: https://github.com/typicode/husky
[lint-staged]: https://github.com/okonet/lint-staged