Skip to content
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

Merged

Conversation

aaronabramov
Copy link
Contributor

No description provided.

let stderr;

({stderr} = runJest(DIR, ['a']));
expect(stderr).toMatch('Ran all test suites matching "a"');
Copy link
Contributor Author

@aaronabramov aaronabramov Jul 10, 2017

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/');

Copy link
Contributor Author

@aaronabramov aaronabramov Jul 10, 2017

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

Copy link
Collaborator

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.

Copy link
Member

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.

Copy link
Contributor Author

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-io
Copy link

Codecov Report

Merging #4006 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d8eb23...66b5bbf. Read the comment docs.

@aaronabramov aaronabramov merged commit 33e1a0a into jestjs:master Jul 11, 2017
@aaronabramov aaronabramov deleted the test_path_pattern_message_test branch July 11, 2017 16:43
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants