Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 713 Bytes

no-statement-after-end.md

File metadata and controls

48 lines (36 loc) · 713 Bytes

Ensure t.end() is the last statement executed.

Translations: Français

t.end() should mark the end of your test, and additional statements should not be executed.

Fail

import test from 'ava';

test.cb(t => {
	t.end();
	t.is(1, 1);
});

test.cb(t => {
	t.end();
	console.log('at the end');
});

Pass

import test from 'ava';

test.cb(t => {
	t.is(1, 1);
	t.end();
});
import test from 'ava';

test.cb(t => {
	if (a) {
		// Allowed because no further statements are reachable.
		return t.end();
	}
	if (b) {
		t.end();
		return;
	}
	t.is(1, 1);
	t.end();
});