-
-
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
Print deprecation warnings on CLI flags #5536
Print deprecation warnings on CLI flags #5536
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5536 +/- ##
==========================================
- Coverage 60.63% 60.54% -0.09%
==========================================
Files 213 213
Lines 7311 7328 +17
Branches 3 3
==========================================
+ Hits 4433 4437 +4
- Misses 2877 2890 +13
Partials 1 1
Continue to review full report at Codecov.
|
Couple things to note here:
Good things here:
Pointers for future:
|
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.
Needs test and a changelog update 🙂
}, | ||
{}, | ||
); | ||
const deprecations = new Set(Object.keys(CLIDeprecations)); |
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.
Could you add some tests for this behavior?
Can we now remove |
How can I assert on what is being printed on terminal? |
Add an integration test and snapshot the stdout |
I was trying to add that in the package tests under |
You can add some unit tests for |
I think I am using the I think I am using |
})); | ||
|
||
it('Prints deprecation warnings for CLI flags', () => { | ||
const {stderr, stdout} = runJest(dir, ['--cache']); |
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.
It's an end to end test, so we should assert on real values. Just pass --preprocessorIgnorePatterns
which is already deprecated and you can get rid of mocking jest-config
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.
But the issue is preprocessorIgnorePatterns
is not a CLI arg. It throws an error. None of the existing deprecations are in CLI args
And what happens in the future those deprecations are removed from the code. That's why I thought I should mock 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.
Maybe we add an internal/undocumented cli arg/config like --printDeprecated
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'd prefer being able to mock it rather than adding a hidden options. That maybe the last resort.
|
||
it('Prints deprecation warnings for CLI flags', () => { | ||
const {stderr, stdout} = runJest(dir, ['--cache']); | ||
expect(stderr).toMatchSnapshot(); |
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.
It's sufficient to just do a regex check for Test Suites: 1 passed, 1 total
.
Snapshot contains changing data (execution time) which breaks on other machines, unless you replace them with something static.
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.
Will do.
1400a03
to
1c2b47c
Compare
How can I mock |
Looks like there is no other way to do this. |
8eac9ce
to
f620a4c
Compare
@Aftabnack I'd either add |
Since my other PR is merged. I can use |
f620a4c
to
86ca4ae
Compare
@@ -47,5 +46,4 @@ module.exports = { | |||
installCommonGlobals, | |||
isInteractive, | |||
setGlobal, | |||
validateCLIOptions, |
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.
technically a breaking change. not sure if it matters, though
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.
It absolutely matters. Please see #5749
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.
Nice, thanks!
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
Test plan