Skip to content
← All rules
TestsTest effectiveness

tests/require-specific-error-assertions

Throw and rejection assertions should check a stable class, code, message contract, or equivalent discriminator unless any failure is intentionally acceptable.

errorsassertionsspecificity
TypeScript
await expect(load("missing")).rejects.toThrow();
Finding

Require assertions that identify the expected failure.

Setup

Install the package, register its plugin factory, then enable the rule.

Install the package

pnpm add -D @scruple/tests

Register the plugin

In scruple.config.ts, register the factory under the tests namespace used by the rule ID.

import { tests } from "@scruple/tests";

plugins: {
  "tests": tests(),
},

Enable the rule

"tests/require-specific-error-assertions": "warn"
Package
@scruple/tests
Default threshold
Plugin default
Minimum confidence
Plugin default

Released under the MIT License.