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

--findRelatedTests overrides --testPathPattern #5129

Closed
emilgoldsmith opened this issue Dec 19, 2017 · 14 comments
Closed

--findRelatedTests overrides --testPathPattern #5129

emilgoldsmith opened this issue Dec 19, 2017 · 14 comments

Comments

@emilgoldsmith
Copy link
Contributor

Do you want to request a feature or report a bug?
Report what I believe is a bug (It doesn't seem to be expected behaviour from my research)

What is the current behavior?
I'm running jest --testPathPattern=PATTERN --findRelatedTests on a precommit hook with lint-staged and it runs tests that don't match with pattern

If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.

Clone https://github.com/emilgoldsmith/jest-bug and you can try running yarn run correct-behaviour and yarn run buggy-behaviour to see the difference.

What is the expected behavior?
It should check for all related tests that they fit the testPathPattern, and in the case of yarn run buggy-behaviour it should return the exactly same as yarn run correct-behaviour, and therefore not find any tests.

Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.

I'll just provide what I used in the example repo I created above:

node v9.3.0
yarn v1.3.2
default yarn configuration
OS: Ubuntu 16.04

@SimenB
Copy link
Member

SimenB commented Dec 19, 2017

I agree it makes sense that testPathPattern is just a filter applied on top of files returned by findRelatedTests. PR welcome!

@emilgoldsmith
Copy link
Contributor Author

Might find time for a PR at some point, but for now if anyone else wants this functionality I just changed to using the --config option and using the testPathIgnorePatterns config option for the directory I wanted to exclude.

@stipsan
Copy link
Contributor

stipsan commented Jul 25, 2018

For those looking to help out on this one, this PR solves a similar problem and might be useful to check out: #6736 🙂

@keepitsimple
Copy link

keepitsimple commented Mar 11, 2019

@emilgoldsmith

using the testPathIgnorePatterns config option for the directory I wanted to exclude.

doesn't work either. findRelatedTests overrides this key too

@mackness
Copy link
Contributor

Hi @SimenB is this still something that needs attention?

@jeysal
Copy link
Contributor

jeysal commented Mar 30, 2019

@mackness I just double-checked, this bug still occurs, so yes a fix would be appreciated :)

@natterstefan
Copy link

Hi, I would appreciate it as well. 👍

@mackness
Copy link
Contributor

mackness commented Apr 9, 2019

@jeysal @natterstefan I am having a little bit of trouble figuring out where to get started with this issue but I am still looking into it!

@jeysal Do you think all of the changes will be isolated to this file: https://github.com/facebook/jest/blob/master/packages/jest-config/src/normalize.ts or do you think there are other parts of the codebase I should be considering?

Thanks for help!

@jeysal
Copy link
Contributor

jeysal commented Apr 10, 2019

@mackness Off the top of my head I think SearchSource would be where most (if not all) changes would be needed to implement this :)

@mackness
Copy link
Contributor

mackness commented Apr 10, 2019

@jeysal Awesome I think I'm on the right track, might have a PR soon :)

@mackness
Copy link
Contributor

Hi @jeysal just want to make sure my change is headed in the right direction. If you think it make sense I can write a couple tests for _getTestPaths. Thanks for your help.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions
Copy link

This issue 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 Apr 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants