Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Latest loopback mocha tests are not running

Abierto
#9,561 1 comentario 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
nodejs, typescript
Área
testing-qa

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
5.1k
Forks
1.1k
Merge medio
4 d 4 h
PR fusionados (30 d)
44

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de loopbackio/loopback-next

Todos los issues de loopbackio/loopback-next

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.