jest: [Bug]: Jest doesnt transform file from node_modules even with empty ignore settings
Version
29.1.2
Steps to reproduce
UPD: just use this repo: https://github.com/iassasin/jest-bug-repro
- Place somewhere 2 files:
package.json
:
{
"dependencies": {
"@babel/core": "^7.19.3",
"@babel/preset-env": "^7.19.3",
"babel-jest": "^29.1.2",
"jest": "^29.1.2",
"parsinator": "2.1.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"node_modules"
],
"transform": {
"\\.[jt]sx?$": "babel-jest"
},
"transformIgnorePatterns": [],
"verbose": false
},
"babel": {
"env": {
"test": {
"plugins": [
"@babel/plugin-transform-modules-commonjs"
]
}
}
}
}
jest.test.js
:
import Parsinator from 'parsinator';
npm install
npx jest
Expected behavior
No errors, all fine
Actual behavior
export { ParseError, VERSION, between, buildExpressionParser, choice, count, debugTrace, end, fail, fromGenerator, many, many1, map, maybe, peek, regex, regexMatch, run, runToEnd, sepBy, sepBy1, sequence, str, surround, until, wrapFail };
^^^^^^
SyntaxError: Unexpected token 'export'
> 1 | import Parsinator from 'parsinator';
| ^
2 |
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1678:14)
at Object.<anonymous> (jest.test.js:1:1)
Additional context
Tried "transformIgnorePatterns": ["^$"],
, "transform": {".*": "babel-jest"}
whatever doesn’t work
Environment
OS: Linux KDE Neon 5.25 (20.04)
CPU: x86_64
Node: 16.17.1
npm: 8.15.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 18
Your problem is now with the
include
option in your babel configuration. It doesn’t match your source file so it just ignores your source file when parsing. Remove it and then it works fine for me.