Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

324
Views
Why Jest failing on node-fetch giving syntax error on import

I'm trying to understand how to fix the following error using Jest in my unit tests in NodeJS.

The test run with this command "test": "NODE_ENV=test jest spec/* -i --coverage --passWithNoTests",

Jest error

I'm also using babel and this is my config

{
  "presets": [["@babel/env", { "targets": { "node": "current" } }]],
  "plugins": [
    "@babel/plugin-syntax-dynamic-import",
    ["babel-plugin-inline-import", { "extensions": [".gql"] }],
    ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ]
}

In package.json I have this

"jest": {
    "verbose": true,
    "collectCoverageFrom": [
      "spec/**/*.js"
    ]
  },

I tried several guides online but cannot find a solution to this

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you have .babelrc try to rename it to babel.config.js

Source: https://babeljs.io/docs/en/configuration#whats-your-use-case

but also this (there's more in the discussion) Jest won't transform the module - SyntaxError: Cannot use import statement outside a module

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!