loopbackio / loopbackio/loopback-next

Latest loopback mocha tests are not running

Ouverte
#9,561 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

bug Testlab
Langage dominant
TypeScript
Étoiles
5.1k
Forks
1.1k
Merge moyen
2 j 21 h
PR mergées (30 j)
27

Description

### 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. (/home/fahad/work/testapp/node_modules/yargs/node_modules/cliui/build/index.cjs:291:21)
at Object. (/home/fahad/work/testapp/node_modules/yargs/build/index.cjs:2861:12)
at Object. (/home/fahad/work/testapp/node_modules/yargs/yargs:3:69)
at Object. (/home/fahad/work/testapp/node_modules/mocha/lib/cli/cli.js:15:15)
at Object. (/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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
nodejs, typescript
Domaine
testing-qa
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.