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.
01 Examples
TypeScript
expect(expiredAt).toBeGreaterThan(Date.now());Finding
Disallow uncontrolled inputs that make tests flaky.
02 Enable it
Setup
Install the package, register its plugin factory, then enable the rule.
Install the package
pnpm add -D @scruple/testsRegister 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