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

transformIgnorePatterns fails on Windows #4033

Closed
samhunta opened this issue Jul 14, 2017 · 9 comments
Closed

transformIgnorePatterns fails on Windows #4033

samhunta opened this issue Jul 14, 2017 · 9 comments

Comments

@samhunta
Copy link

samhunta commented Jul 14, 2017

Do you want to request a feature or report a bug?

bug

What is the current behavior?

transformIgnorePatterns does not support both Windows and Unix systems together. I've had success with regular expressions using windows directory separators, as well as unix directory separators, but not both in the array of transformIgnorePatterns in the package.json of my project.

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.

Add to package.json:

"transformIgnorePatterns": [
  "<rootDir>/node_modules/(?!@myorg/.*)",
  "<rootDir>\\node_modules\\(?!@myorg\\.*)"
]

Run jest with this configuration on Windows 10 and it fails to even locate test files.

What is the expected behavior?

To disable transformation for matches of specified regular expression on Windows and Unix for transformIgnorePatterns config option.

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

Node: v6.9.5
Jest: v20.0.4
Yarn: v0.24.5
OS: Windows 10 / OSX 10.12.5

@samhunta samhunta changed the title transformIgnorePatterns fails on Windows. transformIgnorePatterns fails on Windows Jul 14, 2017
@kumarharsh
Copy link

I'm on Windows and Ubuntu, and it does work for me...

This are my settings:

settings = {
  ...
  transformIgnorePatterns: ['node_modules/(?!.+/es/)'],
}

btw, I'm not using any <rootDir> stuff.

@thymikee
Copy link
Collaborator

@kumarharsh closing then. Happy to reopen if this is still happening for anybody providing a repro repo.

@xlijun
Copy link

xlijun commented May 27, 2018

@thymikee I am experiencing the same issue on windows 10 x64. I've created a repo to reproduce the problem here: repo

The error msg:

({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import square from './square';

SyntaxError: Unexpected token import

at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:396:17)

@SimenB
Copy link
Member

SimenB commented May 27, 2018

@crystal-goose jest does not transform your code if you haven't set up babel

@xlijun
Copy link

xlijun commented May 27, 2018

I set babel up in the project, still has the same problem.
First I tried babel 7, which is the same version with my previous project, the error holds.
Then I rm -rf node_modules, delete package-lock.json, npm install babel 6, the error is still there.

In the other project I am working, both babel and webpack is configured and working properly.

I've push both the babel 7 and babel 6 config to the repo.

@SimenB
Copy link
Member

SimenB commented May 27, 2018

@crystal-goose you haven't configured babel though - you need to set up import/export transforms in a babelrc file or similar.

Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@xlijun
Copy link

xlijun commented May 27, 2018

@SimenB Sorry for not including the .babelrc file. The problem seems to be with babel 7. For babel 6 it works.

In the repo I put two project for babel 6 and 7 side by side, with the same configuration. The babel 7 project always ignore the "transfromIgnorePatters" option and throwing error for the es6 modules from node_modules.

@SimenB
Copy link
Member

SimenB commented May 27, 2018

That's #6229

@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 May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants