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

676
Views
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 answers
Answer question

0

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

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