Skip to content

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.

License

Notifications You must be signed in to change notification settings

nRFCloud/vitest-autogen

 
 

Repository files navigation

Vitest AutoGen

badgenpm badgenpm

About

Automates creation of initial unit test files for vite/vitest, taking dependencies into account.

This tool will take a ts file as input and generate a vitest 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 jest-test-gen, which itself is a fork of jasmine-unit-test-generator. However, this focuses on several changes:

  • Adds default templates for vite/vitest
  • Only uses Typescript as input
  • Remove functionality for React to focus on TS generation

Usage

Installation

run npm i -g vitest-autogen

Basic Usage

run vitest-autogen <path-to-file>

Development

It's probably best to:

  • add an input file in spec/fixtures folder test.ts
  • 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 vitest-autogen <option> in your project of choice

Release

run npm run build run npm publish

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 91.4%
  • Smarty 8.1%
  • JavaScript 0.5%