Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/egm0121/jest-test-gen
This tool will take a js/ts file as input and generate a jest unit test file next to it with all imports mocked and tests stubs for every class method and function exported.
https://github.com/egm0121/jest-test-gen
es6-classes es6-modules jest scaffolding typescript unit-test unit-test-generator
Last synced: 3 months ago
JSON representation
This tool will take a js/ts file as input and generate a jest unit test file next to it with all imports mocked and tests stubs for every class method and function exported.
- Host: GitHub
- URL: https://github.com/egm0121/jest-test-gen
- Owner: egm0121
- License: other
- Fork: true (FDIM/jasmine-unit-test-generator)
- Created: 2021-10-05T23:41:21.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-05T04:26:47.000Z (almost 2 years ago)
- Last Synced: 2024-05-19T14:34:01.886Z (6 months ago)
- Topics: es6-classes, es6-modules, jest, scaffolding, typescript, unit-test, unit-test-generator
- Language: TypeScript
- Homepage:
- Size: 1.27 MB
- Stars: 179
- Watchers: 7
- Forks: 26
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-jest - jest-test-gen
README
# JestTestGen
![badgenpm](https://img.shields.io/npm/dm/jest-test-gen.svg) ![badgenpm](https://img.shields.io/npm/v/jest-test-gen.svg)## 🚀 Try jest-test-gen as a VS Code Extension
**The VS Code extension is the fastest way to generate a unit test file from a source file directly from the IDE**
[Install jest-test-gen Extension](https://marketplace.visualstudio.com/items?itemName=com-egm0121.vs-jest-test-gen)
## About
Automates creation of initial unit test files taking dependencies into account.
Parsing and test generation is avaialable for the following exports:
* Typescript typed React class components 🆕
* Typescript typed Functional components 🆕
* React Functional components 🆕
* React Class based components 🆕
* ES6 Classes default export or named exports
* Exported named functions and arrow functions
* Exported POJOs with methods
* Async functions and methodsThis tool will take a js/ts file as input and generate a jest unit test file next to it with all imports mocked and tests stubs for every class method and function exported.
This project is inspired and started as a fork of [jasmine-unit-test-generator](https://github.com/FDIM/jasmine-unit-test-generator)
## Preview
Basic ES6 Class example:
![Basic](./assets/demo.jpg)
React Component example:
![ReactComponent](./assets/component.jpg)
## Usage
### Installation
run `npm i -g jest-test-gen`
### Basic Usage
run `jest-test-gen `
## Development
It's probably best to:
* add an input file in `spec/fixtures` folder test.js
* add a snapshot test for the input spec in `integration.spec.ts`
* verify that the snapshot is actually the wanted test output before commiting the updated snapshot.Alternavely, you can:
* run `npm link`
* run `npm run build:dev`
* run `jest-test-gen ` in your project of choice## Release
run `npm run build`
run `npm publish`