no-test-return-statement
July 3, 2026 Β· View on GitHub
π Disallow returning a concrete non-Promise value from a test or hook.
πΌπ« This rule is enabled in the β
recommended config. This rule is disabled in the βοΈ unopinionated config.
node:test awaits a Promise returned from a test or hook to know when asynchronous work finishes, but it ignores concrete non-Promise return values. So return 42 or return someObject in a test or hook is dead code, usually a sign that an assertion or an await was intended instead.
This rule is type-aware: it uses TypeScript type information to tell a returned Promise from a plain value, so it only flags concrete non-Promise returns and never the idiomatic return doAsyncWork(). void, undefined, and null are treated like returning nothing. It does nothing when type information is unavailable (plain JavaScript, or TypeScript linted without a type-checked configuration), so it never produces false positives there. Only returns belonging to the test or hook callback itself are checked; returns inside nested helper functions are ignored.
Examples
import test, {beforeEach} from 'node:test';
import assert from 'node:assert/strict';
// β
test('title', () => {
return 42;
});
// β
Assert instead of returning
test('title', () => {
assert.equal(computeValue(), expected);
});
// β
Returning a Promise is how you signal async completion
test('title', () => doAsyncWork());
// β
Hooks can also return a Promise
beforeEach(() => doAsyncSetup());