You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it will fail to find a test located at /I/contain/(parentheses)/index.test.js. If the parentheses are removed from the enclosing path, the test will be found correctly.
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.
Switch to the directory containing parens in its name: cd with-\(parens\)/
yarn install
yarn test
What is the expected behavior?
A the test at with-(parens)/index.test.js should be found and run. If instead you switch to the without-parens directory (and install) and run tests, the test will be found correctly.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
macOS 10.12.6
node 6.10.3
npm 3.10.10
jest 20.0.4 & 21.2.1
Some more info
A teammate ran into this first with a new app using create-react-app (1.4.3). They found that our Jenkins workers were unable to find any tests. It's similar enough in effect to a problem I ran into last year (#1315) that it feels like a regression.
I'm not familiar with the current layout of Jest, but I tried investigating a bit. It seems to me like the issue is caused by rootDir being interpolated into the glob strings contained by testMatch. Since these are passed to micromatch as globs, unescaped parens (and I suppose any other globbing characters) will cause unexpected behavior. I looked around for a place to fix this issue, but couldn't tell what exactly the right thing to do would be. It looks like possibly escaping rootDir's glob characters at https://github.com/facebook/jest/blob/165efcd55b7dce6da348e9f4a661185e02b66c71/packages/jest-config/src/normalize.js#L447 fixes the problem, but I don't know if that's the right place. It seems like the _replaceRootDirTags function is maybe a better candidate, but I don't know what the implications of that would be for the rest of the code.
Ideally, the type system would be able to catch this kind of problem by distinguishing between Glob and Path types (while still remembering that they're both subtypes of strings), but I don't know if that distinction is possible with Flow.
The text was updated successfully, but these errors were encountered:
rimunroe
changed the title
Jest interprets testMatch containing <rootDir> incorrectly if rootDir contains parentheses
Jest interprets testMatch strings containing <rootDir> incorrectly if rootDir contains parentheses
Nov 3, 2017
@rimunroe would you be able to send a PR with your fix? We have a bunch of tests and integration tests, so I think any potential regression would be picked up there
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.
Do you want to request a feature or report a bug?
I think this is a bug
What is the current behavior?
If a project is created under a path
/I/contain/(parentheses)
, and Jest is configured like so:it will fail to find a test located at
/I/contain/(parentheses)/index.test.js
. If the parentheses are removed from the enclosing path, the test will be found correctly.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
andyarn test
.git clone [email protected]:rimunroe/jest-parentheses-in-rootDir.git
cd with-\(parens\)/
yarn install
yarn test
What is the expected behavior?
A the test at
with-(parens)/index.test.js
should be found and run. If instead you switch to thewithout-parens
directory (and install) and run tests, the test will be found correctly.Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
macOS 10.12.6
node 6.10.3
npm 3.10.10
jest 20.0.4 & 21.2.1
Some more info
A teammate ran into this first with a new app using create-react-app (1.4.3). They found that our Jenkins workers were unable to find any tests. It's similar enough in effect to a problem I ran into last year (#1315) that it feels like a regression.
I'm not familiar with the current layout of Jest, but I tried investigating a bit. It seems to me like the issue is caused by
rootDir
being interpolated into the glob strings contained bytestMatch
. Since these are passed to micromatch as globs, unescaped parens (and I suppose any other globbing characters) will cause unexpected behavior. I looked around for a place to fix this issue, but couldn't tell what exactly the right thing to do would be. It looks like possibly escapingrootDir
's glob characters at https://github.com/facebook/jest/blob/165efcd55b7dce6da348e9f4a661185e02b66c71/packages/jest-config/src/normalize.js#L447 fixes the problem, but I don't know if that's the right place. It seems like the_replaceRootDirTags
function is maybe a better candidate, but I don't know what the implications of that would be for the rest of the code.Ideally, the type system would be able to catch this kind of problem by distinguishing between Glob and Path types (while still remembering that they're both subtypes of strings), but I don't know if that distinction is possible with Flow.
The text was updated successfully, but these errors were encountered: