Skip to content
← All rules
TestsTest reliability

tests/no-nondeterministic-tests

Control direct randomness and wall-clock sources with seeds or fake clocks unless nondeterminism itself is the behavior under test.

randomnesstimedeterminism
TypeScript
expect(expiredAt).toBeGreaterThan(Date.now());
Finding

Disallow uncontrolled inputs that make tests flaky.

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/no-nondeterministic-tests": "warn"
Package
@scruple/tests
Default threshold
Plugin default
Minimum confidence
Plugin default

Released under the MIT License.