Skip to content

no-bare-return-from-test-catch

Disallow a bare return from a test catch block when it skips a later assertion.

Why

An unasserted catch return can swallow a failure and skip later assertions; the complete test result also depends on other assertions and hooks.

Fix

Rethrow the error, assert on it, or use the runner's explicit skip mechanism when the capability is optional.

Examples

Before — flagged Do not silently pass
src/codec.test.ts
test("decodes", () => {
try {
decode();
} catch {
return;
}
expect(result()).toBe("ok");
});
After — preferred Preserve the failure
src/codec.test.ts
test("decodes", () => {
try {
decode();
} catch (error) {
throw error;
}
expect(result()).toBe("ok");
});

Files

**/*.test.***/*.spec.***/tests/****/__tests__/**