loopbackio / loopbackio/loopback-next
Latest loopback mocha tests are not running
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 5.1k
- Forks
- 1.1k
- Ø Merge
- 2 T. 21 Std.
- Gemergte PRs (30 T.)
- 27
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Run yarn test in a newly created LoopBack app using Node 16 and inspect the generated test setup and dependency versions around Mocha and yargs. Done means the default Mocha tests run without the reported ERR_REQUIRE_ESM failure while retaining the intended dependency versions.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- nodejs, typescript
- Bereich
- testing-qa
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100