Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

principle-test-behavior-not-implementation: listed matchers do not all pass when imports return undefined

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

维护者通常 1 天内回复

@Yi-111-a 已经在做这个了。

开始于 2026年10月1日。

  • #476 来自 @Yi-111-a —— 未关闭
  • #487 来自 @lab1207 —— 未关闭

评估

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

调研方向

从 pstack/skills/principle-test-behavior-not-implementation/SKILL.md 开始,尤其查看第 15-18 行,并将列出的每个 matcher 与 issue 中展示的未定义行为进行比较。更新说明或分组,使关于未定义行为的说法仅适用于实际通过的 matcher,同时准确描述较弱但非空洞的断言。

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

描述

Observed at commit 2eb7ed4613cfc8f098dfe464a23680ea44d84c5e: pstack/skills/principle-test-behavior-not-implementation/SKILL.md lines 15-18.

The skill's check is "would the test still pass if every function it imports returned undefined?" and it lists, as "Five shapes that still pass when every imported function returns undefined", assertions such as:

  • toBeDefined, toBeTruthy, toBeInstanceOf, toBeGreaterThan(0)
  • toEqual([]), toHaveLength(0)
Problem

Several of these do not pass when the value is undefined:

expect(undefined).toBeDefined()        // fails
expect(undefined).toBeTruthy()         // fails
expect(undefined).toBeInstanceOf(Foo)  // fails
expect(undefined).toBeGreaterThan(0)   // throws (received value must be a number)
expect(undefined).toEqual([])          // fails
expect(undefined).toHaveLength(0)      // throws (received value must have a length property)

They are weak assertions, but the stated reason ("still passes when every import returns undefined") is false for them, which can lead an agent following the rule to delete tests that do fail when the function breaks, or to distrust the check. (not.toThrow, toBeUndefined, not.toHaveBeenCalled and a missing expect do pass.)

Suggested fix

Describe the principle by what the test can detect rather than by matcher name: ask whether the assertion would still pass if the function returned a wrong but plausible value (an empty array, true, a different object). Either remove the matchers that fail on undefined from the list, or move them to a separate "weak but not vacuous" group with the accurate explanation, and keep the undefined claim only for the matchers that truly pass.

主要语言
TypeScript
星标
9.7k
派生
919
平均合并
14 小时 37 分钟
30 天内合并 PR
66

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

cursor/plugins 的其他 Issue

查看 cursor/plugins 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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