jest-test-generator v0.1.2
Jest Tests Generator (OpenAI based)
UNDER DEVELOPMENT!!! If you are having any issues please open an issue on github Generates Jest tests cases: 1 base case, 1 edge case, and 1 error case. Supports JavaScript and TypeScript. Test are generated in same directories as source files as filename.test.extension files. If such file already exists, append new tests to it.
Attention:
- OpenAPI has rate limits, so if you have a lot of files to generate tests for, you might want to process one file at a time.
- Output can differ from run to run, because of the nature of the model.
REQUIRES OPENAI_API_KEY environmental variable, you can get key at https://platform.openai.com/account/api-keys
You can install it locally
npm i jest-test-generator
\
add add script to package.json
"scripts": {
"generate": "jest-test-generator ./src"
}
Or globally to use it as a command line tool
npm i -g jest-test-generator
Usage
Argument \
target
: file, files or directory to generate tests for
Option \
-c, --no-cache
: do not cache functions, cached functions are skipped. (default: true
) \
-f, --full
: use full files as an input for the generator, instead of per function, caching does not work in this mode. (default: false
) \
-v, --verbose
: print more information (default: false
) \
-d, --davinci
: use text-davinci-002 model instead of gpt-3.5-turbo (default: false
)
By default it extracts functions from files and processes them one by one. use -f flag to process files as a whole.