---
url: https://scruple.dev/rules/tests/no-nondeterministic-tests.md
description: Disallow uncontrolled inputs that make tests flaky.
---

# tests/no-nondeterministic-tests

Disallow uncontrolled inputs that make tests flaky.

## What it checks

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

## Rule metadata

* Package: `@scruple/tests`
* Category: Test reliability
* Tags: randomness, time, determinism
* Default threshold: `plugin default`
* Minimum confidence: `plugin default`

## Examples

### Reported

```ts
expect(expiredAt).toBeGreaterThan(Date.now());
```

### Accepted

```ts
vi.setSystemTime(new Date("2025-01-01")); expect(expiredAt).toBeGreaterThan(Date.now());
```
