generator-jest
Add jest support to any projects
Installation
First, install Yeoman and generator-jest using npm (we assume you have pre-installed node.js).
npm install -g yo generator-jest
Then generate your new project:
yo jest
Once done, you can run tests using npm test
.
To generate tests for your components, you can then run:
yo jest:test path/to/file-to-test.js
yo jest:test path/to/file-to-test.js --componentName=useThisName
Include generator-jest in your own generator
generator-jest
is built to create as minimum overhead as possible when including in your own generators.
First, install generator-jest
as a dependency of your own generator.
npm install --save generator-jest
Then call it from your generator.
this.composeWith(require.resolve('generator-jest/generators/app'), {
testEnvironment: 'jsdom',
coveralls: true
});
this.composeWith(require.resolve('generator-jest/generators/test'), {
filepath: 'components/Sidebar.jsx'
componentName: 'SideBar'
});
Note: Tests generated by jest:test
will fail by default. Users should implement relevant tests.
License
MIT © Simon Boudrias