jest can't find babel when i'm using gitDir
See original GitHub issueHello okonet, thank you for your great work. I’m trying to use jest with lint staged, but when i’m using the “gitDir” option jest can’t find babel-jest and so every test fails.
My config:
{
"gitDir": "../",
"linters": {
"*.js": [
"prettier --single-quote --trailing-comma all --write",
"git add",
"eslint --ignore-path ./gui/.gitignore",
"jest --config ./gui/jest.json --bail --findRelatedTests"
],
"*.css": [
"stylelint"
]
}
}
My folder structure: gitFolder -> gui (frontend-app)
^^^^^^ SyntaxError: Unexpected token import at transformAndBuildScript (gui/node_modules/jest-runtime/build/transform.js:320:12)
I think the problem is that jest can’t find babel-jest, because of the “gitDir”-option and so can’t transform the import statement.
When i’m using jest without lint-staged it’s working like a charm.
lint-staged: 3.4.0 jest: 19.0.2 babel-jest: 19.0.0 husky: 0.13.3
I hope you’ve got an idea where the problem comes from. Thank you
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:16 (9 by maintainers)
Top Results From Across the Web
0 - Stack Overflow
I have an app inside my nx project, which uses array-move. When writing a test for this app, jest crashes with: Details: ....
Read more >babel-preset-jest - npm
Start using babel-preset-jest in your project by running `npm i babel-preset-jest`. There are 392 other projects in the npm registry using ...
Read more >Today I Learned - Selleo
This happens only if we hide it with display: none , because it cannot find the source of the gradient (eg. fill =...
Read more >Where the Prolog version of Vue died (JS Party #135)
An amalgam of interest on this week's episode starting with a peek at what's finally coming in Vue 3. We talk about the...
Read more >babel-jest | Yarn - Package Manager
Usage. If you are already using jest-cli , add babel-jest and it will automatically compile JavaScript code using Babel.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @DeFuex, in the test i recommend to change the button id to something different for example “fooBar”. After changing the test you have to add the change to git with
git add .
before you are runningnpm run precommit
. This is necessary for lint-staged to see the edited files.@okonet thanks, i will do it tomorrow.