Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.59 KB

no-ignored-test-files.md

File metadata and controls

52 lines (36 loc) · 1.59 KB

Ensure no tests are written in ignored files

Translations: Français

This rule will verify that files which create tests are treated as test files by AVA. It will consider the root of the project to be the closest folder containing a package.json file, and will not do anything if it can't find one. Test files in node_modules will not be linted as they are ignored by ESLint.

Fail

// File: test/_helper.js
// Invalid because a helper.
const test = require('ava');

test('foo', t => {
	t.pass();
});

// File: lib/foo.js
// Invalid because not a test file.
const test = require('ava');

test('foo', t => {
	t.pass();
});

Pass

// File: test/foo.js
const test = require('ava');

test('foo', t => {
	t.pass();
});

Options

This rule supports the following options:

  • extensions: an array of extensions of the files that AVA recognizes as test files or helpers. Overrides both the babel.extensions and extensions configuration otherwise used by AVA itself.
  • files: an array of glob patterns to select test files. Overrides the files configuration otherwise used by AVA itself.
  • helpers: an array of glob patterns to select helper files. Overrides the helpers configuration otherwise used by AVA itself.

See also AVA's configuration.

You can set the options like this:

"ava/no-ignored-test-files": ["error", {"files": ["lib/**/*.test.js", "utils/**/*.test.js"]}]