Skip to content

No Trivial Assertions

Error
small-rules/no-trivial-assertions

Disallow assertions that always succeed or compare against freshly created values.

Diagnostic Messages

freshIdentity
Use `{{matcher}}` instead; freshly-created values are never identical to other values.
freshPredicate
Replace this assertion; the value is freshly created here, so the result is independent of the code under test.
issue
Replace this assertion; it always succeeds.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-trivial-assertions": "error"
}
}

Examples

Constant always-true equality
expect(true).toBe(true);
Non-constant assertion
expect(result).toBe(true);