test: class-diagnostics fails when FORCE_COLOR is set

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

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
testing

调研方向

从 tests/class-diagnostics.test.ts 开始:第 88 行会过滤以 error: 开头的 stderr 行,构建在第 26 行通过 Bun.spawnSync 使用继承的环境启动。用 FORCE_COLOR=1 bun test tests/class-diagnostics.test.ts 复现,然后在做前缀检查前去除 ANSI 转义序列,或者在没有 FORCE_COLOR 的情况下启动子进程。当该文件在设置和不设置 FORCE_COLOR 时都报告 4 pass, 0 fail 时即完成。

由索引模型根据 Issue 内容生成。

描述

bug

Version

PocketJS main (2c9fcf30). macOS 27.2 arm64, Bun 1.4.2.

Repro

FORCE_COLOR=1 bun test tests/class-diagnostics.test.ts

Actual

 3 pass
 1 fail

The failing test is --strict-classes fails on the ones in a class attribute and writes no bundle. It expects three lines and receives none:

- [
-   "error: main.tsx:6:15: class "flex-col items-centre gap-2" does not compile: unknown utility items-centre",
-   "error: main.tsx:7:49: class "text-smal font-bold" does not compile: unknown utility text-smal",
-   "error: main.tsx:9:17: class "hiden" does not compile: unknown utility hiden",
- ]
+ []

With FORCE_COLOR unset the file reports 4 pass, 0 fail.

Expected

The test passes with or without FORCE_COLOR in the environment.

Cause

tests/class-diagnostics.test.ts:88 keeps the stderr lines of the build that start with error: . The build runs as a child process (Bun.spawnSync, line 26) and inherits the environment. With FORCE_COLOR set, Bun writes colour codes before and inside the error: prefix, so no line matches.

CI does not set the variable. A terminal or an agent harness that exports FORCE_COLOR=1 sees one failure in the unit stage of bun tools/test.ts.

Workaround

env -u FORCE_COLOR bun test tests/class-diagnostics.test.ts
主要语言
TypeScript
星标
1.6k
派生
88
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

pocket-stack/pocketjs 的其他 Issue

查看 pocket-stack/pocketjs 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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