# generator-jest

> Add jest support to any projects

Latest version **1.8.0** (published 2020-06-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install generator-jest
pnpm add generator-jest
yarn add generator-jest
bun add generator-jest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.8.0 |
| Published | 2020-06-27 |
| First published | 2016-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | Simon Boudrias |
| Maintainers | sboudrias |
| Keywords | jest, node, react, test, yeoman-generator |

## Links

- npm: https://www.npmjs.com/package/generator-jest
- Repository: https://github.com/SBoudrias/generator-jest
- Homepage: https://github.com/SBoudrias/generator-jest#readme
- Issues: https://github.com/SBoudrias/generator-jest/issues
- npm.io page: https://npm.io/package/generator-jest

## Dependencies (5)

- [snyk](https://npm.io/package/snyk.md) ^1.349.0
- [deep-extend](https://npm.io/package/deep-extend.md) ^0.6.0
- [lodash.camelcase](https://npm.io/package/lodash.camelcase.md) ^4.3.0
- [yeoman-generator](https://npm.io/package/yeoman-generator.md) ^4.10.1
- [lodash.upperfirst](https://npm.io/package/lodash.upperfirst.md) ^4.3.1

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.8.0 (latest) — 2020-06-27
- 1.7.0 — 2019-07-20
- 1.6.0 — 2018-08-27
- 1.5.1 — 2018-03-26
- 1.5.0 — 2018-01-14
- 1.4.2 — 2017-10-22
- 1.4.1 — 2017-09-16
- 1.4.0 — 2017-09-11
- 1.3.0 — 2017-05-26
- 1.2.0 — 2017-02-23
- 1.1.0 — 2016-12-31
- 1.0.0 — 2016-12-25
- 0.1.1 — 2016-12-01
- 0.1.0 — 2016-12-01

## README

# generator-jest [![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][codecov-image]][codecov-url]

> Add jest support to any projects

## Installation

First, install [Yeoman](http://yeoman.io) and generator-jest using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).

```bash
npm install -g yo generator-jest
```

Then generate your new project:

```bash
yo jest
```

Once done, you can run tests using `npm test`.

To generate tests for your components, you can then run:

```bash
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.

```bash
npm install --save generator-jest
```

Then call it from your generator.

```js
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](https://github.com/SBoudrias)

[npm-image]: https://badge.fury.io/js/generator-jest.svg
[npm-url]: https://npmjs.org/package/generator-jest
[daviddm-image]: https://david-dm.org/SBoudrias/generator-jest.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/SBoudrias/generator-jest
[codecov-image]: https://codecov.io/gh/SBoudrias/generator-jest/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/SBoudrias/generator-jest

---
_Source: https://npm.io/package/generator-jest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
