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

オープン 初心者向け
#292 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github-actions, node.js, typescript

調査の方向性

e2e/helpers/run-cli.ts から始め、e2e テストで runCli を呼び出して終了コードを検証する方法を確認してください。issue では e2e/cli-login.test.ts が例として挙げられています。#274 で CLI の出力をアサーションメッセージとして渡す方法を確認し、e2e/ 以下にあるすべての終了コードの検証に出力を含めて、失敗時に stdout と stderr が表示されるようにしてください。すべての該当する検証に出力が含まれ、e2e テストが通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
2
フォーク
2
平均マージ
2日 18時間
マージ済み PR(30日)
17

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NanoForge-dev/CLI のほかの issue

NanoForge-dev/CLI の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。