Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

325
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda