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 seems not working with babel v7

See original GitHub issue

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

What is the current behavior? I get an TypeError: Cannot read property 'loose' of undefined (While processing preset: "/Users/x/Desktop/jest-test/node_modules/babel-preset-react-app/index.js") on using jest v22.4.2 with babel v7

I’ve searched for this error and found this Bug in Babel, which suggests that when babel-core instead of @babel/core is required by any package, it will break. And it seems like jest-runtime v22.4.2 (currently the newest one) is doing exactly this.

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. I created this GitHub Repo

What is the expected behavior? No error and it works with babel v7

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

  • Operating System: MacOS 10.13.2 (High Sierra)
  • Nodejs: v9.4.0
  • npm: v5.7.1

(all other dependencies can be found in the aforementioned GitHub Repo)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15

github_iconTop GitHub Comments

3reactions
hannadrehmancommented, Sep 3, 2018

same issue. i have @babel/core and babel-core@^7.0.0-0 installed. the strange thing is when i try to use .babelrc' it works. but when i use babel.config.jsit dosent work in that case. here is mybabel.config.js`

  const babelConfig = (api) => {
  // api.cache.never();
  const config = {
    presets: [
      ['@babel/preset-env', { modules: false, useBuiltIns: 'usage' }],
      '@babel/preset-react',
    ],
    plugins: [
      'react-hot-loader/babel',
      '@babel/plugin-proposal-object-rest-spread',
      '@babel/plugin-proposal-class-properties',
      '@babel/plugin-syntax-dynamic-import',
      ['import', { libraryName: 'antd', libraryDirectory: 'es', style: false }],
      [
        'module-resolver',
        {
          root: [
            './src',
          ],
          alias: {
            App: './src/App',
            Common: './src/App/Common',
            Elements: './src/App/Elements',
            Router: './src/App/Router',
            Constants: './src/Constants',
            Services: './src/Services',
            Store: './src/Store',
            Styles: './src/Styles',
            Assets: './src/Assets',
          },
        },
      ],
    ],
  };
  if (api.env('test')) {
    config.presets.splice(0, 1, ['@babel/preset-env', { useBuiltIns: 'usage' }]); // if i remove this nothing changes
    config.plugins.push('@babel/plugin-transform-modules-commonjs');
  }
  return config;
};

module.exports = babelConfig; 

2reactions
dneprocommented, Mar 6, 2018

Ahh forget it, in the Docs its npm install --save-dev babel-jest 'babel-core@^7.0.0-0' @babel/core regenerator-runtime, so both babel-core and @babel-core need to be installed 🤐 must have missed that, sorry ✌️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems getting Jest to work with Babel 7.0.0 - Stack Overflow
I posted a bug report with the Jest repository, but they closed it saying my problem was not a bug and that I...
Read more >
Config Files - Babel.js
Project-wide configuration ... New in Babel 7.x, Babel has a concept of a "root" directory, which defaults to the current working directory. For...
Read more >
babel-jest | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
babel-jest - npm
Start using babel-jest in your project by running `npm i babel-jest`. There are 7377 other projects in the npm registry using babel-jest.
Read more >
Remove babel 7.0.0-bridge after Jest is upgraded - GitLab.org
Link issues together to show that they're related or that one is blocking others. Learn more. Activity. Sort ...
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