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

未关闭 适合新手
#292 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
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 小时
30 天内合并 PR
17

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NanoForge-dev/CLI 的其他 Issue

查看 NanoForge-dev/CLI 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。