Skip to content
weftGitHub

Diagnostics

T008

Conditional expect (if, ?:, &&, catch), or a test whose only expects are in a loop.

Fix: Make the condition its own assertion, then assert unconditionally; expect(fn).toThrow() for errors.

Status in weft@0.1.0: reported by weft check on test files.

Triggers it:

tsx
test('maybe', () => { const xs = [1, 2]; if (xs.length > 5) expect(xs[0]).toBe(1) })

A test that needs it on purpose keeps it with a reason: // weft-allow T008: <why> in the file header (whole file) or on the line above.

More: weft docs testing.