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.

babel-jest plugin & babel 7 incompatibility

See original GitHub issue

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

What is the current behavior? babel-7-jest does work for me. babel-jest does not work for me.

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.

What is the expected behavior? When I run test suite using babel-7-jest: screen shot 2018-02-11 at 11 19 42 am

When I run test suite using babel-jest:

 TypeError: Cannot read property 'loose' of undefined (While processing preset: "/Users/alechp/Code/servexyz/repospace/cli/node_modules/@babel/preset-env/lib/index.js")

All that is required to make these tests pass is toggle the “transform” option in Jest config from “babel-jest” to “babel-7-jest” (note: I have both installed right now for easy swapping, but I have tried executing babel-jest after having removed babel-7-jest from dependencies and clearing cache)

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

Relevant dependencies, jest configuration and babel configuration

"devDependencies": {
    "@babel/core": "^7.0.0-beta.39",
    "@babel/node": "^7.0.0-beta.39",
    "@babel/preset-env": "^7.0.0-beta.39",
    "babel-7-jest": "^21.3.3",
    "babel-jest": "^22.2.2",
    "jest": "^22.2.2"
  },
  "jest": {
    "verbose": true,
    "bail": false,
    "collectCoverage": false,
    "modulePathIgnorePatterns": ["sandbox", "node_modules"],
    "transform": {
      "^.+\\.jsx?$": "babel-jest"
    }
  },
  "babel": {
    "presets": [
      [
        "@babel/preset-env",
        {
          "targets": {
            "node": "9.3.0"
          }
        }
      ]
    ]
  }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

40reactions
thymikeecommented, Feb 11, 2018
10reactions
wmertenscommented, Jul 27, 2018

So I installed babel-core@bridge and I still get babel-core from jest-config and jest-runtime:

$ npm ls babel-core
proj@0.0.1 /path/proj
├── babel-core@7.0.0-bridge.0
└─┬ jest-cli@23.4.1
  ├─┬ jest-config@23.4.1
  │ └─┬ babel-core@6.26.3
  │   └─┬ babel-register@6.26.0
  │     └── babel-core@6.26.3
  └─┬ jest-runtime@23.4.1
    └── babel-core@6.26.3

maybe -config and -runtime should declare babel-core as a peerDependency?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade to Babel 7
This means there will be no more issues with accidental/intentional name squatting, a clear separation from community plugins, and a simpler naming convention....
Read more >
babeljs - Laravel Mix: Configure Babel for IE11 compatibility ...
Enable Babel compilation with Laravel Mix, and use polyfills for internet explorer. Step 1: Install Corejs to get polyfills.
Read more >
babel-jest - npm
Jest plugin to use babel for transformation.. Latest version: 29.3.1, last published: 2 months ago. Start using babel-jest in your project ...
Read more >
babel-plugin-jest-hoist | Yarn - Package Manager
Babel plugin to hoist jest.disableAutomock , jest ... This plugin is automatically included when using babel-jest ... yarn add --dev babel-plugin-jest-hoist ...
Read more >
Documentation - Using Babel with TypeScript
Babel vs tsc for TypeScript. When making a modern JavaScript project, you might ask yourself what is the right way to convert files...
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