Skip to content

mbtts/babel-node-mocha-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reproduction

This reproduces tests which pass using:

And fail using:

Node.js v20.19.0

❌ Mocha tests (using Babel register) fail:

pnpm test

> mocha "src/**.test.js"

 Exception during run: SyntaxError[ @/src/component.test.js ]: Unexpected token '<'
    at compileSourceTextModule (node:internal/modules/esm/utils:340:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:146:18)
    at #translate (node:internal/modules/esm/loader:431:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:478:27)
    at async ModuleJob._link (node:internal/modules/esm/module_job:110:19)

✅ Babel register on its own works:

pnpm start

> node --require @babel/register src/index.js

<p>Test component</p>

Node.js v20.18.3

✅ Mocha tests (using Babel register) pass:

pnpm test

> mocha "src/**.test.js"

  component test
    ✔ exports a component


  1 passing (1ms)

✅ Babel register on its own works:

pnpm start

> node --require @babel/register src/index.js

<p>Test component</p>

About

Reproduces failing tests on latest Node.js 20 release (with require ESM)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published