Skip to content

test(integration): per-test TEST_DIR for 7 remaining flake-prone test files#433

Merged
vrogojin merged 1 commit into
mainfrom
test/per-test-testdir-integration-flakes
Jun 8, 2026
Merged

test(integration): per-test TEST_DIR for 7 remaining flake-prone test files#433
vrogojin merged 1 commit into
mainfrom
test/per-test-testdir-integration-flakes

Conversation

@vrogojin

@vrogojin vrogojin commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to PR #432. Same flake class (Wallet already exists from Sphere.create() under parallel-worker load) was surfaced on PR #326's CI in wallet-clear.test.ts. Six other integration test files share the same shared-TEST_DIR pattern and are equally exposed — fixing them all proactively.

Root cause

Mirror of commit 9bf3e90 and PR #432: shared path.join(__dirname, '.test-X') plus cleanTestDir() in beforeEach/afterEach races with FileStorageProvider's proper-lockfile path. Sphere.exists() can see a partially-saved wallet.json from a prior test → Sphere.create() throws.

Fix

Mirrors 9bf3e90/#432: each beforeEach generates a fresh per-test TEST_DIR under os.tmpdir() with Date.now() + random suffix. afterEach still runs cleanTestDir() to keep tmpdir from growing.

Files

  • tests/integration/wallet-clear.test.ts (the one that surfaced this)
  • tests/integration/provider-disable-sync.test.ts
  • tests/integration/operator-escape-hatch-bootstrap.test.ts
  • tests/integration/history-sync.test.ts (custom DEVICE_A/B_DIR)
  • tests/integration/tracked-addresses.test.ts
  • tests/integration/market-module.test.ts (custom cleanupTestDir)
  • tests/integration/nametag-overwrite-guard.test.ts

Test plan

  • Full integration suite: 486/486 pass, 9 skipped
  • Typecheck clean

… files

Follow-up to PR #432 (which fixed the same flake in
`nametag-normalization.test.ts`). Surfaced on PR #326's CI: the
`wallet-clear.test.ts > destroy() shuts down tokenStorageProviders >
should not throw if tokenStorage shutdown fails` test failed with
`Wallet already exists. Use Sphere.load() or Sphere.clear() first.`
at `Sphere.create()` — exact same flake class as commit 9bf3e90 and
PR #432 fixed.

Root cause (mirror of 9bf3e90 + #432): seven additional integration
test files use shared `path.join(__dirname, '.test-X')` directories
with cleanTestDir() in beforeEach/afterEach. Under parallel-worker
load, the FS race between cleanTestDir() and the next test's
`Sphere.init` → `Sphere.exists` lets a partially-saved wallet.json
from the FileStorageProvider's proper-lockfile path slip through —
exists() returns true when it shouldn't and Sphere.create throws.

Fix mirrors 9bf3e90/#432: each beforeEach now generates a fresh
per-test TEST_DIR under `os.tmpdir()` with `Date.now()` + random
suffix. tmpfs gives no fsync / no cross-process lock contention,
and the unique path guarantees zero FS interaction between tests
in the same file. afterEach still runs cleanTestDir() to keep
tmpdir from growing.

Files fixed:
  - tests/integration/wallet-clear.test.ts
  - tests/integration/provider-disable-sync.test.ts
  - tests/integration/operator-escape-hatch-bootstrap.test.ts
  - tests/integration/history-sync.test.ts (custom DEVICE_A/B_DIR)
  - tests/integration/tracked-addresses.test.ts
  - tests/integration/market-module.test.ts (custom cleanupTestDir)
  - tests/integration/nametag-overwrite-guard.test.ts

Verified:
  - Full integration suite: 486/486 pass, 9 skipped (no regression).
  - Typecheck clean.
@vrogojin vrogojin merged commit 302b865 into main Jun 8, 2026
3 checks passed
@vrogojin vrogojin deleted the test/per-test-testdir-integration-flakes branch June 8, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant