Skip to content

No Test Timeout

Suggestion
small-rules/no-test-timeout

Disallow per-test timeouts in unit tests.

Rationale

A slow unit test is a design problem, and a longer timeout hides it. Mock or inject the file system, network, subprocesses, and timers, or remove the dependency. The rule reports a timeout argument after a test, it, or describe callback, and a timeout key in a Vitest options object. It follows chains such as .only, .skip, .concurrent, .each, .for, and .skipIf. Enable it for unit test files only; integration and end-to-end tests may need the time.

A config-level testTimeout, hook timeouts, and waitFor options pass. So does it(name, run, TIMEOUT), which reads the same as test(name, options, run). additionalTestFunctions adds the names of your own test or suite functions.

Diagnostic Messages

noTestTimeout
Per-test timeouts are banned. A slow unit test is a design problem: mock or inject the file system, network, subprocesses, and timers, or remove the dependency, so the test runs fast. Do not raise the timeout or disable this rule.

Configuration

This rule accepts one options object after the severity.

additionalTestFunctionsOptional

Names of test or suite functions to check besides describe, fit, it, test, xit, and xtest

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-test-timeout": [
"error",
{
"additionalTestFunctions": []
}
]
}
}

Examples

Timeout argument on a test
test('loads the config', async () => {}, 5000);
Test without a timeout
test('loads the config', async () => {});