@studio/related-tests

0.2.0 • Public • Published

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.

npm i @studio/related-tests -D

lint-staged.config.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'):

{
  "scripts": {
    "test": "npm run test:files -- './{,!(node_modules)/**}/*.test.js'",
    "test:files": "mocha --require test/hooks.js"
  }
}

Package Sidebar

Install

npm i @studio/related-tests

Weekly Downloads

37

Version

0.2.0

License

MIT

Unpacked Size

4.89 kB

Total Files

4

Last publish

Collaborators

  • mantoni
  • whybuzz