Skip to content

chore(test): de-sequentialize temp-dir tests via per-test TmpDir context - #9916

Merged
mmaietta merged 7 commits into
masterfrom
chore/de-sequence-tests
Jun 17, 2026
Merged

chore(test): de-sequentialize temp-dir tests via per-test TmpDir context#9916
mmaietta merged 7 commits into
masterfrom
chore/de-sequence-tests

Conversation

@mmaietta

Copy link
Copy Markdown
Collaborator

Summary

Removes the test-suite's reliance on { sequential: true } for temp-directory isolation so those blocks run in parallel again.

The suite runs concurrent: true by default. A recurring anti-pattern forced blocks back to serial:

describe("…", { sequential: true }, () => {
  let tmpDir: string                              // shared closure variable
  beforeEach(async context => {
    tmpDir = await context.tmpDir.createTempDir()  // clobbered per test under concurrency
  })
  test("…", async ({ expect }) => { /* reads outer tmpDir */ })
})

The per-test tmpDir plugin already gives every test its own context.tmpDir. The only bug was storing the created path in a module-scoped let tmpDir that interleaved beforeEach calls overwrite — { sequential: true } was a workaround for that race. Fix: create the temp dir inside each test from the per-test context, in a local const:

test("…", async ({ expect, tmpDir }) => {
  const tmpDirPath = await tmpDir.createTempDir()
  
})

Design notes

  • s3PublishTest.ts was intentionally left unchanged. Its three blocks stay sequential (https.request mock + __TEST_S3_PUBLISHER__ env), their beforeEach already uses the per-test context.tmpDir correctly, and the value tests read is a derived testFile/srcDir built in beforeEach — not tmpDir directly. A per-test conversion would inline file+mock setup into ~15 tests with no parallelism gain.

  • A few sequential: true blocks remain untouched because they serialize for non-tmpDir reasons: archiveUtilTest.ts compute7zCompressArgs (vi.stubEnv) and winSignToolManagerTest.ts PKCS#11 PIN via env var.

  • Concurrency gotcha: toMatchSnapshot() must use the test-context expect, not the global expect import. blockmapTest.ts used the global expect and failed once de-sequentialized; fixed by destructuring expect from each test context and dropping the global import. winReseditTest.ts (also snapshot-based) already used context expect.

@changeset-bot

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d624bc9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mmaietta
mmaietta marked this pull request as ready for review June 16, 2026 14:59
@mmaietta
mmaietta merged commit eba12de into master Jun 17, 2026
170 of 172 checks passed
@mmaietta
mmaietta deleted the chore/de-sequence-tests branch June 17, 2026 00:02
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