Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

generator-jest NPM version Dependency Status Coverage percentage

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

# (optional) You can specifically define your component name
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', // (optional) pass one of jsdom or node
  coveralls: true // (optional) send coverage reports to coveralls
});

this.composeWith(require.resolve('generator-jest/generators/test'), {
  filepath: 'components/Sidebar.jsx'
  componentName: 'SideBar' // (optional) define the component name
});

Note: Tests generated by jest:test will fail by default. Users should implement relevant tests.

License

MIT © Simon Boudrias