Socket
Socket
Sign inDemoInstall

generator-jest

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generator-jest

Add jest support to any projects


Version published
Maintainers
1
Created
Source

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

Keywords

FAQs

Package last updated on 27 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc