Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#474 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
88/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
documentation

Direzione di ricerca

Inizia da pstack/skills/principle-test-behavior-not-implementation/SKILL.md, in particolare dalle righe 15-18, e confronta ogni matcher elencato con il comportamento indefinito mostrato nell’issue. Aggiorna la spiegazione o il raggruppamento in modo che l’affermazione di comportamento indefinito si applichi solo ai matcher che passano effettivamente, mentre le asserzioni deboli ma non vacue siano descritte accuratamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
8.8k
Fork
819
Merge medio
14h 37m
PR unite (30g)
66

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cursor/plugins

Tutte le issue di cursor/plugins

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.