-
-
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 --showConfig argument #3296
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3296 +/- ##
==========================================
+ Coverage 63.9% 64.23% +0.33%
==========================================
Files 176 176
Lines 6475 6465 -10
Branches 4 4
==========================================
+ Hits 4138 4153 +15
+ Misses 2336 2311 -25
Partials 1 1
Continue to review full report at Codecov.
|
it('outputs config info and exits', () => { | ||
/* eslint-disable sort-keys */ | ||
const {stdout} = runJest(dir, ['--showConfig', '--no-cache']); | ||
expect(JSON.parse(stdout)).toEqual({ |
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.
We should change this to a snapshot test... If there are any fullPaths we can fix them with a serializer for paths that replaces /some/full/path/
-> /mocked/full/path/
, something like:
const rootPath = path.resolve(/* resolve root path */);
expect.addSnapshotSerializer({
test: val => typeof val === 'string' && val.startsWith(rootPath),
print: val => val.replace(rootPath, '/mocked/root/path'),
})
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.
Sounds good. I was going to do snapshot at first but because of the paths, I went this way. Will add the serializer and change this to a snapshot.
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.
Let me know if you have some questions about the serializer 👍
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.
Yeah, snapshot sounds like a great idea here. Don't wanna keep this in sync manually.
packages/jest-cli/src/cli/runCLI.js
Outdated
const config = readConfig(argv, root); | ||
if (argv.showConfig) { | ||
const output = ({config}) => { | ||
pipe.write(JSON.stringify(config, null, 2)); |
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.
Based on what @cpojer mentioned I think we can make this use logDebugMessage
and update logDebugMesage
to print out a JSON... Is that ok @cpojer?
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, maybe we can move this to where argv.debug is used
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.
Ah, I didn't see that right below inside of _run
. I agree, I'll get that moved.
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 said back in the issue that it appeared to be 2 changes here. One being adding this flag and outputting JSON config. The other being to change --debug
output to be JSON as well. I'm willing to make the change in this PR, but I figured they would be separate changes therefor separate PRs.
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 think we can do it in a single PR.
Alright, changed the test over to snapshot and made the additional requested changes. One thing I couldn't get working is the Settings test for |
@@ -15,42 +15,37 @@ jest.mock('../../../package.json', () => ({version: 123})); | |||
jest.mock('myRunner', () => ({name: 'My Runner'}), {virtual: true}); |
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.
This file lacks 'use strict';
declaration, can you add it?
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.
Sure thing!
expect.addSnapshotSerializer({ | ||
print: val => val.replace(new RegExp(root, 'g'), '/mocked/root/path'), | ||
test: val => typeof val === 'string' && val.indexOf(root) > -1, | ||
}); |
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.
You also need to change "name"
to something like "[MD5 HASH]"
because by default it gets assigned random hash.
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 noticed that last night before I went to bed. Will get that fixed up!
ab88e82
to
290fd30
Compare
I've updated the original description to include everything changed in here. I tried my best adding a test for the |
cc @orta – we may need to make the code in jest-editor-support work with older releases prior to 20. |
* Add --showConfig argument * Update CLI.md
* Add --showConfig argument * Update CLI.md
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
This solves #3288. It adds a JSON output of the config and then exits.
--showConfig
argument.--debug
output to be JSON.jest-editor-support
package to use--showConfig
.Test plan
jest --showConfig
outputs config and exits.