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

677
Visualizações
Jest not running tests - Error while loading config - You appear to be using a native ECMAScript module configuration file

I'm having a problem configuring Jest to run my tests. When running npm test -- --watchAll --no-cache I get the message

babel.config.js: Error while loading config - You appear to be using a native ECMAScript module configuration file, which is only supported when running Babel asynchronously.

I've already checked other issues here on the OS, notably this one, but when I change the extension from babel.config to .cjs, the following message appears

Jest encountered an unexpected token

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

By default "node_modules" folder is ignored by transformers.

Details:

SyntaxError: <project_root>/src/filmes/gerenciador.js: Unexpected reserved word 'await'. (13:24)

Below is my configuration files

package.json

{
    "name": "myfilms",
    "version": "1.0.0",
    "type": "module",
    "description": "",
    "main": "index.js",
    "scripts": {
        "test": "jest"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "@babel/core": "^7.15.0",
        "@babel/preset-env": "^7.15.0",
        "babel-jest": "^27.0.6",
        "jest": "^27.0.6",
        "json-server": "^0.16.3"
    },
    "dependencies": {
        "axios": "^0.21.1",
    }
}

babel.config.js

module.exports = {
    presets: [
        [
            "@babel/preset-env",
            {
                targets: {
                    node: "current",
                },
            },
        ],
    ],
};

Jest's and Babel's documentation is pretty confusing about these cases, and each of the solutions I try alternates between these two types of errors. Is there any standard way to configure Jest to support imports/exports and await/async?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I have the same problem right now, were you able to solve it?

almost 4 years ago · Carlos Pinda 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