Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉 適合新手
#474 3 則留言 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
星號
13.9k
分支
1.4k
平均合併
7 小時 2 分鐘
30 天內合併 PR
153

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

cursor/plugins 的其他 Issue

查看 cursor/plugins 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。