-
-
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
testPathPattern message test #4006
testPathPattern message test #4006
Conversation
let stderr; | ||
|
||
({stderr} = runJest(DIR, ['a'])); | ||
expect(stderr).toMatch('Ran all test suites matching "a"'); |
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.
there is a lot of complexity around this case in the codebase.
We create a testPathPattern
string and pass it all the way through the entire test flow to SummaryReporter
just so that we can print "a"
instead of /a/
, even though if we pass multiple parrterns we still print /a|b/
at the end.
example:
$> ./jest matchers.test
...
Ran all test suites matching "matchers.test".
but:
$> ./jest matchers.test matchers1.test
Ran all test suites matching /matchers.test|matchers1.test/.
this complexity can be avoided if we always print the pattern (and not a string). This way we can just put testPathPattern
into globalConfig
and remove it from everywhere else (run_jest.js, TestSelectionConfig, ReporterOptions, formatTestPathPattern, argv and a few other places).
if we do this, the only change to this test will be this like, and it'll look like this:
({stderr} = runJest(DIR, ['a']));
expect(stderr).toMatch('Ran all test suites matching /a/');
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.
if we absolutely must print double quotes for single string arguments, i'd rather replace /
at the end of the run.
(/a/ => "a'
, or `/matchers.test/ => "matchers.test").
in my opinion id' rather see the actual pattern that was used to match the tests rather than the passed string (also the input string is pretty much a regexp)
./jest (matcher|reporter)(\\.|\\-)test\.js
...
Ran all test suites matching "(matcher|reporter)(\.|\-)test.js". // this does not look right to me
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 there was some idea behind this? But I like showing regex here. To be even more precise, we could change the message to:
Ran all test suites matching pattern /some.*regex/
Similar to what we do in watch mode.
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 printing the exact regex that is run on all the paths is beneficial. Whatever you type on the terminal might not be what ends up inside of Jest as the regex, because of different terminals and expansions and the like. Showing what Jest does gives a hint to engineers when they are using Jest incorrectly.
If the way this is implemented isn't clean, then we can fix that, but it doesn't make sense to degrade the user experience to simplify the architecture of the code in an immaterial way.
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.
so by switching to showing the regexp instead of the original input we can simplify the design and improve the experience. which is win/win.
I'll merge this tests and update it to expect the regexp when i change the implementation.
Codecov Report
@@ Coverage Diff @@
## master #4006 +/- ##
=======================================
Coverage 60.26% 60.26%
=======================================
Files 196 196
Lines 6765 6765
Branches 6 6
=======================================
Hits 4077 4077
Misses 2685 2685
Partials 3 3 Continue to review full report at Codecov.
|
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. |
No description provided.