question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jest can't find babel when i'm using gitDir

See original GitHub issue

Hello 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
bmsuseludacommented, May 8, 2017

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 running npm run precommit. This is necessary for lint-staged to see the edited files.

0reactions
bmsuseludacommented, May 8, 2017

@okonet thanks, i will do it tomorrow.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found