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());