`jest --init` to set up package.json with default values
See original GitHub issue🚀 Feature Proposal
Much like other tools (tsc, tslint, etc), it would be very useful if there were an --init
option for jest cli to supplement the existing package.json with all possible settings for jest, with their default values.
Motivation
This would make custom configuration easier: instead of having to refer to documentation every time, one could simply jest --init
and look for the setting which describes what it does to edit that.
Example
# jest --init
Pitch
Because jest
is the master of the configuration which is available – it makes sense that jest
should be able to populate these settings. Ideally, this --init would also guide the user through some more common options, such as:
- “Is this a TypeScript project?” (positive answer enables the
ts-jest
transform, alters “testMatch” to “**/.spec.ts", adds “ts” to “moduleFileExtensions”, adds "/.\.d\.td/” to “watchIgnorePatterns”, etc - “Do you want coverage reports?” (positive answer sets “coverageDirectory” to “coverage” (ignored by default with github .gitignore for node projects)
- “Would you like Jest to use Jest for ‘npm test’?” (positive answer sets “test” npm script to “jest”)
Jest already provides probably the best test running framework I’ve used (between jasmine, mocha and jest), with so many things already baked in (coverage! What a win!) – it just seems like one of the aims of the project is to be as polished as possible. A guided --init would, imo, help a lot.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:22 (10 by maintainers)
Top GitHub Comments
This is done #6442
Typescript detection added:
I’ve added a short explanation for each option and changed the looks of the generated file:
All
undefined
values should be corrected after #6428 will be merged.@rickhanlonii Is that something we can start with?