Skip to content
Add jest support to any projects
Branch: master
Clone or download
greenkeeper and SBoudrias Update husky to the latest version 🚀 (#40)
* chore(package): update husky to version 2.0.0

* chore(package): update lockfile package-lock.json
Latest commit 0dfc51f Apr 25, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
generators Add --coverage to pkg.script.test if coveralls is selected (#23) Mar 26, 2018
.editorconfig
.eslintignore
.gitattributes
.gitignore
.travis.yml Bump dependencies Aug 27, 2018
.yo-rc.json
LICENSE
README.md
package-lock.json Update husky to the latest version 🚀 (#40) Apr 25, 2019
package.json

README.md

generator-jest NPM version Build Status 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

You can’t perform that action at this time.