unit-test-quality/test-data-management penalise real in-memory implementations and require mocks
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- testing-qa
Direzione di ricerca
Start by locating the rules and tests for unit-test-quality-standards and test-data-management, then trace how they determine whether tests use mocks. The issue offers two alternative directions, so clarify which behavior is wanted before changing anything. Done means the tests cover the chosen policy and real in-memory implementations are no longer penalized unfairly.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: 7.17.6
Laws: unit-test-quality-standards, test-data-management
What happens
Both laws report against test suites that deliberately use real in-memory
implementations instead of mocks:
• Dependencies found but no mocking detected in .../launch.page.spec.ts
• Dependencies found but no mocking detected in .../capability-matrix.spec.ts
• External dependencies are not properly mocked in tests
Every one of those files is a suite we would hold up as an example. The laws
are asking us to weaken them.
Why this is the wrong direction
A mock asserts that the code agrees with the test author's belief about a
collaborator, rather than with the collaborator. Two concrete cases from this
repository:
1. InMemoryPlatformCapabilityService runs the same resolution function
and the same capability matrix as production. Only the reported environment
differs. Mocking it would mean asserting against a hand-written table that can
drift from the real matrix — which is exactly the bug the tests exist to catch.
2. InMemoryResourceEnvironment keeps a real monotonic clock and a real
task queue that the test advances. It replaced a faked-timer approach precisely
because fake timers hide the ordering bugs a polling primitive is prone to:
overlapping refreshes, a stale alarm firing after teardown, a poll scheduled
from inside a finally.
Both are strictly stronger than mocking the collaborator away. Under these laws
they score worse than a suite full of jest.fn() that asserts nothing about
real behaviour.
That is the definition of a checkbox that lies, and it is the one thing our
engineering canon forbids outright — so we are reporting it rather than
complying, and rather than waiving it.
Suggested fix
Two options, either would work:
- Detect test doubles by role, not by framework. A class named
InMemory*/Fake*/Stub*injected in place of a real collaborator is
a test double. The current check appears to look only for a mocking library. - Invert the law toward the property that matters: "a unit test must not
reach real I/O — no network, no filesystem, no wall clock". That is what
mocking is a means to, and it can be detected directly. A suite using real
in-memory implementations passes it honestly; a suite that quietly hits the
network fails it, which today's version does not catch.
(2) would also have caught a genuine bug in a sibling repository, where a test
was found to be making a live network call.
- Lingua principale
- TypeScript
- Stelle
- 0
- Fork
- 0
- Merge medio
- 38m
- PR unite (30g)
- 96
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Rule-Of-Code/RoC
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Rule-Of-Code/RoC#436 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Rule-Of-Code/RoC#439 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 49/100
Rule-Of-Code/RoC#438 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 53/100
Rule-Of-Code/RoC#437 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 74/100
Rule-Of-Code/RoC#435 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Rule-Of-Code/RoC
Issue simili
-
documentation lens:human needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
thebristolsound/birdbrain#2246 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
A voting window past about 69.9 million hours stores a deadline that reads back as no deadlineApertabug ready-for-human
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
BoardGamesEmpire/board-games-empire-backend#1452 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue stretch
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno