Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time

Test timeouts

Translations: Fran莽ais

Open in StackBlitz

Timeouts in AVA behave differently than in other test frameworks. AVA resets a timer after each test, forcing tests to quit if no new test results were received within the specified timeout. This can be used to handle stalled tests.

The default timeout is 10 seconds.

You can configure timeouts using the --timeout command line option, or in the configuration. They can be set in a human-readable way:

npx ava --timeout=10s # 10 seconds
npx ava --timeout=2m # 2 minutes
npx ava --timeout=100 # 100 milliseconds

t.timeout(ms, message?)

Timeouts can also be set individually for each test. These timeouts are reset each time an assertion is made. The test fails if it takes more than ms for an assertion to be made or the test to complete.

test('foo', t => {
	t.timeout(100); // 100 milliseconds
	// Write your assertions here

An optional message string can be provided. This can be useful if your test depends on some other setup that may not have been completed:

test('foo', t => {
	t.timeout(100, 'make sure database has started'); // 100 milliseconds
	// Write your assertions here