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.

v8.0 config with jest

See original GitHub issue

Since CommonJS has been removed in v8, it works fine with webpack but hard with jest.

It makes transformIgnorePatterns need to config like react-dnd, dnd-core

I’m not sure if its a correct time or little earlier to remove CommonJS version.

ref: https://github.com/facebook/jest/issues/4842

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
govizloracommented, Jul 4, 2019

@wldcordeiro

transformIgnorePatterns: ['node_modules/(?!(react-dnd|dnd-core|react-dnd-html5-backend)/)']

Worked for my case. Hope it helps

0reactions
RyanZhu1024commented, Sep 27, 2022

I know this is an older issue, but I’m working on a library (created with create-react-library) which uses the react-keyed-file-browser that appears to be dependent on version 8.0 so I’m running into the old issue:

({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import HTML5Backend from './HTML5Backend';
                                                                                         ^^^^^^
SyntaxError: Cannot use import statement outside a module

The documents no longer contain information regarding this. Is it archived anywhere, or is there a newer solution?

I’m having the same issue when running unit tests with Jest. Can’t find any resource online for it. My package.json. It’s typescript project.

    "typescript": "^4.3.2",
    "react-dnd": "^16.0.1",
    "react-dnd-html5-backend": "^16.0.1",
    "jest": "^27.5.1",
node_modules/react-dnd-html5-backend/dist/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { HTML5BackendImpl } from './HTML5BackendImpl.js';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      13 |   Skeleton,
      14 | } from 'antd';
    > 15 | import { HTML5Backend } from 'react-dnd-html5-backend';

Need some help.

Update, Found the solution. Make the below change in the jest.config

  transform: {
    "^.+\\.(j|t)sx?$": 'ts-jest',
  },
  transformIgnorePatterns: [
    '<rootDir>/node_modules/(?!@react-dnd|react-dnd|dnd-core|react-dnd-html5-backend)',
  ],
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Jest
Configuring Jest. The Jest philosophy is to work great by default, but sometimes you just need more configuration power.
Read more >
Set up Jest in Angular in under 7 minutes tutorial ... - YouTube
A full guide to installing and setting up Jest in any Angular 8-10 ... Set up Jest in Angular in under 7 minutes...
Read more >
jest-config | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Jest/Ionic 4 beta - import { Platform } from '@ionic/angular ...
0 but it fails in Jest 23.5.0 as well. I get these errors with or without your babelrc config. For reference, here is...
Read more >
Jest | PyCharm Documentation - JetBrains
The Run/Debug Configuration: Jest dialog opens. ... Otherwise, by default the debug process will use V8 Debugging Protocol.
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