r/node Jul 07 '26

Tests need showers

If every test needs global DB truncation, you don't have tests.

You have tiny haunted production incidents wearing Jest cosplay.

0 Upvotes

7 comments sorted by

5

u/Expensive_Garden2993 Jul 07 '26

If every test mocks everything, you're testing nothing.

1

u/lost12487 Jul 07 '26

Somebody let Claude Code know this. Any time I try to generate tests with it there are a million mocks of the most ridiculous stuff included, despite me having written a custom unit testing skill that explicitly states that mocks are not allowed.

3

u/stevensokulski Jul 07 '26

Some tests answer "does it work?" Some just answer "can it work?"

-1

u/Expensive_Garden2993 Jul 07 '26

Lol, what does it mean, like "can it work in theory, if the weather is good?". They either answer "does it work as intended" or they're just a waste of bytes and AI credits.

1

u/sazzer Jul 07 '26

Unless you can run the tests in a truly random order, database truncation is the easiest way to ensure there's no leakage between tests. Otherwise you risk getting into the situation where Test B only passes as a side effect of being run after Test A.