Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 728 Bytes

no-statement-after-end.md

File metadata and controls

48 lines (36 loc) · 728 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

const test = require('ava');

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

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

Pass

const test = require('ava');

test.cb(t => {
	t.is(1, 1);
	t.end();
});
const test = require('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();
});