loopbackio / loopbackio/loopback-next
Latest loopback mocha tests are not running
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 5.1k
- Fork
- 1.1k
- Merge medio
- 2g 21h
- PR unite (30g)
- 27
Descrizione
Describe the bug
Create a new lb app with node 16,
Trying to run the default tests that come with lb app, using yarn test, it immediately throws this typescript error. This seems to be a mocha issue, but why did Loopback upgrade to latest mocha?
ERR_REQUIRE_ESM errors with Mocha tests.
const stringWidth = require('string-width');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/fahad/work/testapp/node_modules/string-width/index.js from /home/fahad/work/testapp/node_modules/yargs/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js in /home/fahad/work/testapp/node_modules/yargs/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/home/fahad/work/testapp/node_modules/yargs/node_modules/cliui/build/index.cjs:291:21)
at Object.<anonymous> (/home/fahad/work/testapp/node_modules/yargs/build/index.cjs:2861:12)
at Object.<anonymous> (/home/fahad/work/testapp/node_modules/yargs/yargs:3:69)
at Object.<anonymous> (/home/fahad/work/testapp/node_modules/mocha/lib/cli/cli.js:15:15)
at Object.<anonymous> (/home/fahad/work/testapp/node_modules/mocha/bin/mocha.js:141:3) {
code: 'ERR_REQUIRE_ESM'
}
Logs
No response
Additional information
If I downgrade yargs library to 14.2.2, this issue is not occurring.
Reproduction
THIS ISSUE IS OBVIOUS
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Eseguire yarn test in un'applicazione LoopBack appena creata con Node 16 e ispezionare la configurazione di test generata e le versioni delle dipendenze relative a Mocha e yargs. Il lavoro è completato quando i test Mocha predefiniti vengono eseguiti senza l'errore ERR_REQUIRE_ESM segnalato, mantenendo al contempo le versioni delle dipendenze previste.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- nodejs, typescript
- Ambito
- testing-qa
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100