-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add init option #6442
add init option #6442
Conversation
|
|
||
const overrideKeys: Array<string> = Object.keys(overrides); | ||
|
||
const stringifyOption = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this have to exist inside the generateConfigFile
closure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll move it out of there 😉
|
||
const overrides: Object = {}; | ||
|
||
if (typescript) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should add ts-jest - it forces people to install another dependency and babel 7 supports typescript..
@rickhanlonii @thymikee @orta thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also to the problem with ts-jest
is that it may happen that older version will be installed, e.g. right after new Jest major release. Maybe we can add another prompt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this isn't that much of a problem, I've yet to have ts-jest break between jest versions (but I don't see every issue on this repo) and it's triggered on a prompt that checks your dependencies for typescript itself, so using babel's transformer won't necessarily make sense for that kind of setup by default.
I'm really excited by this, thanks for working on it! Code wise I think it looks good, but it would be awesome to have some docs on it (plus a changelog entry 🙂) I'm honestly fine with this just supporting node 8 and up (as it's just something that would be run on a developer's machine), but we'd still need |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to create a new package out of it, like jest-init
or jest-cli-init
? jest-cli
is already quite bloated
@SimenB @thymikee Thanks for the review. I've added docs and a changelog entry. I've also realized that it makes sense to put {
"scripts": {
"test": "jest"
}
} So i've added support for this case, and now we'll not ask the user that add it if it's already there. I agree that we need to decide about how we initialize jest for a typescript project, and that what we currently have is only OKish and has some problems. Regarding prompts, opened another issue with the update asking to remove the |
Update, prompts now supports node 6. |
yarn.lock
Outdated
@@ -7546,6 +7550,13 @@ promise@^7.1.1: | |||
dependencies: | |||
asap "~2.0.3" | |||
|
|||
prompts@^0.1.8: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mind running yarn
so this is updated?
Codecov Report
@@ Coverage Diff @@
## master #6442 +/- ##
==========================================
+ Coverage 63.48% 63.78% +0.29%
==========================================
Files 227 234 +7
Lines 8697 8791 +94
Branches 3 4 +1
==========================================
+ Hits 5521 5607 +86
- Misses 3175 3183 +8
Partials 1 1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks!
Agree with @thymikee, we should move this to |
@ranyitz mind mocking out Asserting on the output might make sense, but if not, just stub it out 🙂 |
@SimenB I agree, I'll do it later on today. |
This Pull Request updates dependency [jest](https://github.com/facebook/jest) from `v23.1.0` to `v23.2.0` <details> <summary>Release Notes</summary> ### [`v23.2.0`](https://github.com/facebook/jest/blob/master/CHANGELOG.md#​2320) [Compare Source](jestjs/jest@v23.1.0...v23.2.0) ##### Features - `[jest-each]` Add support for keyPaths in test titles ([#​6457](`https://github.com/facebook/jest/pull/6457`)) - `[jest-cli]` Add `jest --init` option that generates a basic configuration file with a short description for each option ([#​6442](`https://github.com/facebook/jest/pull/6442`)) - `[jest.retryTimes]` Add `jest.retryTimes()` option that allows failed tests to be retried n-times when using jest-circus. ([#​6498](`https://github.com/facebook/jest/pull/6498`)) ##### Fixes - `[jest-cli]` Add check to make sure one or more tests have run before notifying when using `--notify` ([#​6495](`https://github.com/facebook/jest/pull/6495`)) - `[jest-cli]` Pass `globalConfig` as a parameter to `globalSetup` and `globalTeardown` functions ([#​6486](`https://github.com/facebook/jest/pull/6486`)) - `[jest-config]` Add missing options to the `defaults` object ([#​6428](`https://github.com/facebook/jest/pull/6428`)) - `[expect]` Using symbolic property names in arrays no longer causes the `toEqual` matcher to fail ([#​6391](`https://github.com/facebook/jest/pull/6391`)) - `[expect]` `toEqual` no longer tries to compare non-enumerable symbolic properties, to be consistent with non-symbolic properties. ([#​6398](`https://github.com/facebook/jest/pull/6398`)) - `[jest-util]` `console.timeEnd` now properly log elapsed time in milliseconds. ([#​6456](`https://github.com/facebook/jest/pull/6456`)) - `[jest-mock]` Fix `MockNativeMethods` access in react-native `jest.mock()` ([#​6505](`https://github.com/facebook/jest/pull/6505`)) ##### Chore & Maintenance - `[docs]` Add jest-each docs for 1 dimensional arrays ([#​6444](`https://github.com/facebook/jest/pull/6444`/files)) --- </details> --- This PR has been generated by [Renovate Bot](https://renovatebot.com).
Included `testMatch` and edited `transform` entries to meet [#6442](jestjs/jest#6442) from the Jest community.
Included `testMatch` and edited `transform` entries to meet [#6442](jestjs/jest#6442) from the Jest community.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Following the feature request in #6403 this PR adds
jest --init
option.When a user type
jest --init
in a project directory, he will be prompted with questions that will help jest to create a basic configuration, suitable for the project. It will create ajest.config.js
file and modifypackage.json
if needed.What's inside?
jest-config
cacheDirectory
, the dynamic bit of thedefaults
module, now has it's own module so it'll be easier to mock.jest-cli
--init
options triggers the init process.Thoughts
cacheDirectory
which are less likely to be changed by the user.How does the generated/modified files looks like?
jest.config.js
package.json
Test plan
Verify that each file system condition (e.g. has jest config, has typescript dependency) affects the prompts, and that each response to the prompts changes the way files will e generated.
saved 1 snapshot of the whole generated file with comments, and evaluate each permutation to verify the returned value from the config.