Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Latest loopback mocha tests are not running

Aperta
#9,561 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 7 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
nodejs, typescript
Ambito
testing-qa

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.

Descrizione

bug Testlab
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

Lingua principale
TypeScript
Stelle
5.1k
Fork
1.1k
Merge medio
3g 2h
PR unite (30g)
26

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di loopbackio/loopback-next

Tutte le issue di loopbackio/loopback-next

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.