Every test must genuinely validate the behavior it claims to cover, run deterministically, and avoid noise from redundant or stale cases.
cookies.length instead of the actual cookie values, or asserting generic type inequality instead of the concrete expected type).expect(cookies).toContain('foo=bar; Path=/') over expect(cookies.length).toBe(2), and prefer toBeInstanceOf(ALBProcessor) over a loose truthy check.Math.random(), real network ports, or timing-dependent assumptions in tests — use fixed/mocked values (e.g. mock HTTP servers with msw instead of spinning up a real server on a fixed port, which can collide with other processes), and make sure async event listeners resolve on the correct event (e.g. resolve on close, not open, when testing a close handshake).:: case already covered by a trailing-:: test), and don’t add tests to a module’s suite that belong elsewhere (e.g. generic request-cloning tests inside validator.test.ts). Do not remove existing tests without a replacement unless the behavior they cover is actually gone.report-uri is emitted when unspecified) and boundary inputs (empty input, single-element arrays, trailing slashes, etc.)..only()/.skip() calls, debug console.log/console.debug statements, and unused scaffolding. If any is intentionally used in a test, suppress the lint warning explicitly (// eslint-disable-next-line @typescript-eslint/no-explicit-any) rather than leaving a warning.Example of a weak vs. strong test:
// Weak: passes even with the bug, and only checks length
it('keeps previous cookies', () => {
const res = c.json({ message: 'Hello' })
expect(res.headers.getSetCookie().length).toBe(2)
})
// Strong: verifies actual values, would fail without the fix
it('keeps previous cookies', () => {
const res = c.json({ message: 'Hello' })
const cookies = res.headers.getSetCookie()
expect(cookies).toContain('foo=bar; Path=/')
expect(cookies).toContain('foo2=bar2; Path=/')
})