e2e tests hide the CLI output when an exit code assertion fails

Aperta Adatta ai principianti
#292 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
github-actions, node.js, typescript

Direzione di ricerca

Inizia da e2e/helpers/run-cli.ts e controlla come i test e2e chiamano runCli e verificano i codici di uscita; nell’issue viene citato e2e/cli-login.test.ts come esempio. Verifica come #274 passa l’output della CLI come messaggio dell’asserzione, poi includi l’output in tutte le verifiche dei codici di uscita in e2e/ affinché gli errori mostrino stdout e stderr. Il lavoro è completato quando tutte queste verifiche includono l’output e i test e2e passano.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Which package is this bug report for?

@nanoforge-dev/cli

Which command is this bug report for?

other

Issue description

When an e2e test that spawns nf fails on its exit code, the failure shows only AssertionError: expected 1 to be +0, not what nf printed. The cause then has to be guessed or rerun with extra logging.

  • Most e2e tests destructure only exitCode from runCli and assert expect(exitCode).toBe(0): 50 such assertions under e2e/ on main (e.g. cli-login.test.ts#L63).
  • Found while making the Windows CI pass (#273): 14 Windows failures in install, login, logout, publish and unpublish showed only the exit code, and the cause could only be inferred.
  • #274 adds the CLI output as the assertion message to the 3 nf install (with existing project) tests only, as a diagnostic: expect(exitCode, output).toBe(0), where the message is the CLI's stdout and stderr.

Expected: every exit-code assertion in e2e/ shows the CLI's stdout and stderr when it fails, for example through a helper next to e2e/helpers/run-cli.ts.

Code sample
// e2e/cli-login.test.ts (main)
const { exitCode } = await runLogin(["--local", "--api-key", "test-api-key"]);
expect(exitCode).toBe(0); // on failure: "expected 1 to be +0", nothing else
Versions
  • @nanoforge-dev/cli main (e95b881)
  • Node.js 26
  • Seen on windows-latest GitHub runners; the same on every OS
Issue priority

Low (slightly annoying)

I have tested this issue on a development release

e95b881

Lingua principale
TypeScript
Stelle
2
Fork
2
Merge medio
2g 18h
PR unite (30g)
17

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 NanoForge-dev/CLI

Tutte le issue di NanoForge-dev/CLI

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.