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.

with-jest example doesnt work

See original GitHub issue

when i run test from npm scripts i have error

  C:\with-jest-app\jest.setup.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { configure } from 'enzyme';
                                                                                                    ^
    
    SyntaxError: Unexpected token {
      
      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
Tech Version
next 5.1.0
node 10.0.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:28 (8 by maintainers)

github_iconTop GitHub Comments

15reactions
paulomfrcommented, Aug 3, 2018

Hello there! I added this following .babelrc

{
  "env": {
    "development": {
      "presets": ["next/babel"]
    },
    "production": {
      "presets": ["next/babel"]
    },
    "test": {
      "presets": ["env", "react"]
    }
  }
}

and installed yarn add --dev babel-jest babel-preset-env babel-preset-react

Worked for me.

15reactions
binarykitchencommented, Jun 4, 2018

and now seeing this error

    Plugin 0 specified in "/Users/mick/code/urban-signs/node_modules/next/babel.js" provided an invalid property of "default" (While processing preset: "/Users/mick/code/urban-signs/node_modules/next/babel.js")

      at Plugin.init (node_modules/babel-core/lib/transformation/plugin.js:131:13)
      at Function.normalisePlugin (node_modules/babel-core/lib/transformation/file/options/option-manager.js:152:12)
      at node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
          at Array.map (<anonymous>)
      at Function.normalisePlugins (node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
      at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
      at node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
      at node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
          at Array.map (<anonymous>)
      at OptionManager.resolvePresets (node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Jest example doesn't work - Stack Overflow
Trying to run the example of Jest testing React code (from https://github.com/facebook/jest/tree/master/examples/react ), I get the ...
Read more >
with-jest-app example doesn't work · Issue #37082 - GitHub
After setting up the with-jest example from the documentation, yarn test consistently fails. Expected Behavior. Whether using npx or directly ...
Read more >
Troubleshooting - Jest
Troubleshooting. Uh oh, something went wrong? Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why​.
Read more >
Testing Asynchronous Code - Jest
It's common in JavaScript for code to run asynchronously. When you have code that runs asynchronously, Jest needs to know when the code...
Read more >
Configuring Jest
Configuring Jest. The Jest philosophy is to work great by default, but sometimes you just need more configuration power.
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