avoid_skipped_tests
Warns when a test, group or whole library is switched off with skip: or
@Skip(...). A skipped test still counts as a test: the runner reports it and
exits zero, so the suite keeps growing while the evidence it provides shrinks.
Why use this rule
Section titled “Why use this rule”Every gate downstream stays green. CI passes. A mirror-test presence check like
require_mirror_test
is satisfied, because the file still exists. A coverage gate sees the file
counted but never executed. Nothing in the output says the assertion stopped
running — you have to go looking.
That matters more the less of the code you wrote yourself. Faced with a failing
assertion, adding skip: true is the shortest path to a green run, and it is
invisible in review unless somebody greps for it. It turns a hard gate into a
suggestion, silently.
A grep cannot replace this rule: skip: in a string literal, or a skip
parameter on somebody’s own function, are indistinguishable from the real thing
in text. The AST tells them apart.
See also: package:test — skipping tests | eslint-plugin-jest: no-disabled-tests
// A skip with no reason.test('parses a malformed manifest', () {}, skip: true);
// A reason makes the skip readable, not acceptable — it still proves nothing.test('handles a timeout', () {}, skip: 'flaky on CI');
// A whole group.group('upload', () {}, skip: true);A whole file, as a library annotation — it must be the first directive in the file, so it is shown on its own:
@Skip('needs a real device')library;// Fix the test.test('parses a malformed manifest', () { expect(() => parse(malformed), throwsA(isA<ManifestFailure>()));});
// Or delete it. A deleted test is honest about what is covered;// a skipped one is not.skip: false is never reported. It is a no-op, and occasionally appears as a
deliberate placeholder.
Turning this rule off
Section titled “Turning this rule off”This rule is in the recommended preset, so it is on with
preset: recommended, preset: opinionated or preset: pedantic. Add it to
preset: core with avoid_skipped_tests: true.
To turn it off:
rules: avoid_skipped_tests: falseTo keep the rule on but skip certain paths — a quarantine directory, if your
project wants one — use per-rule exclude.
Options
Section titled “Options”many_lints: rules: avoid_skipped_tests: allow_reason: truerules: avoid_skipped_tests: allow_reason: true| Option | Type | Default | Description |
|---|---|---|---|
allow_reason |
bool | false |
Permit skip: 'reason string', and report only the bare skip: true form |
The default is false because “a documented skip is better than a deleted
test” is a real argument that still does not make the test run. A project that
wants an audit trail can opt into it; leaving it off keeps the default honest.
Related rules
Section titled “Related rules”avoid_focused_tests— Detect tests focused with solo:, which silences their siblings.avoid_misused_test_matchers— Detect test matchers used with incompatible value types.format_test_name— Hold test descriptions to a house pattern.prefer_correct_test_file_name— Name test files so the runner actually runs them.