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

Add testNamePattern CLI argument #1733

Merged
merged 3 commits into from
Sep 20, 2016
Merged

Conversation

fson
Copy link
Contributor

@fson fson commented Sep 17, 2016

Summary
The --testNamePattern <regex> argument (alias -t <regex>) allows running only tests with a name that matches a given regex pattern. Fixes #1662.

Test plan
Added an integration test in integration_tests/__tests__/testNamePattern-test.js.

testNamePattern allows filtering tests by name with a regex
@fson
Copy link
Contributor Author

fson commented Sep 17, 2016

This is still WIP, because at the moment when tests are filtered out, they are treated as skipped and Jest marks the snapshots as obsolete. Here's a screenshot that illustrates the problem (running with --testNamePattern that only matches one test):

obsolete-snapshots

Any ideas how to solve this?

@cpojer
Copy link
Member

cpojer commented Sep 18, 2016

@DmitriiAbramov is working on that separately.

@@ -91,6 +91,11 @@ const options = {
'rare.',
type: 'boolean',
},
testNamePattern: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we give this an alias? Maybe p or t?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe t? I would reserve p for filtering by path, because it means that in the 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.

sounds good 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added:

  --testNamePattern, -t           Run only tests with a name that matches the
                                  regex pattern.                        [string]

@cpojer
Copy link
Member

cpojer commented Sep 18, 2016

This is awesome! Nice work and thanks for adding an integration test. My only comment is whether we should add an alias for this, given that no one will want to write testNamePattern.

@ghost ghost added the CLA Signed ✔️ label Sep 18, 2016
@fson
Copy link
Contributor Author

fson commented Sep 18, 2016

The new integration test did not pass on Windows. Most of the existing integration tests seem to have skipOnWindows.suite();, should I add that to new one as well?

@cpojer
Copy link
Member

cpojer commented Sep 18, 2016

yes please

@codecov-io
Copy link

codecov-io commented Sep 18, 2016

Current coverage is 90.17% (diff: 100%)

Merging #1733 into master will not change coverage

@@             master      #1733   diff @@
==========================================
  Files            31         31          
  Lines          1170       1170          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits           1055       1055          
  Misses          115        115          
  Partials          0          0          

Powered by Codecov. Last update ba12cfa...418ed77

@cpojer cpojer merged commit f8a02cc into jestjs:master Sep 20, 2016
@cpojer
Copy link
Member

cpojer commented Sep 20, 2016

Great work. Thank you for helping make Jest better for everyone :)

@fson fson deleted the cli-test-name-pattern branch September 20, 2016 03:02
mthmulders pushed a commit to mthmulders/jest that referenced this pull request Oct 10, 2016
* Add testNamePattern CLI argument

testNamePattern allows filtering tests by name with a regex

* Add -t as an alias for --testNamePattern

* Skip testNamePattern-test integration test on Windows
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
* Add testNamePattern CLI argument

testNamePattern allows filtering tests by name with a regex

* Add -t as an alias for --testNamePattern

* Skip testNamePattern-test integration test on Windows
@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 14, 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.

CLI option to run test by regexp
4 participants