Invental/Review lessons/Tests that can never fail

Tests that can never fail

Negative tests must create what they exclude

A negative test (“X is never included”) has to create X first. Otherwise it passes because X doesn't exist, and it proves nothing about the guard it is named after.

01 · Before and afterThe pattern

TypeScript
// before: passes forever: nothing to exclude, key omitted when empty
const pkg = await promote(project);
expect(pkg.manifest.agents).toBeUndefined();

// after: seed the thing that must stay out, then look at what was actually written
await agents.save({ id: 'a1', projectId: project.id, ... });
const pkg = await promote(project);
expect(await readEntities(pkg.dir, 'agent.json')).toEqual([]);

02 · Run it on your appThe check

For each “must never include / never leak” test in your suite, does the test first create the thing that must not appear?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.