Skip to content

test(oci): isolate network tests from shared HTTP interceptors - #1776

Open
bdehamer wants to merge 1 commit into
mainfrom
bdehamer-oci-test-reliability
Open

bdehamer wants to merge 1 commit into
mainfrom
bdehamer-oci-test-reliability

Conversation

@bdehamer

Copy link
Copy Markdown
Collaborator

The real-transport tests in packages/oci/src/__tests__/network.test.ts fail intermittently on Linux and Windows CI runners (see the test failures on #1772 and #1773). They pass when run alone but fail when the full suite runs other suites first in the same worker.

Cause

Other suites leave process-wide HTTP interceptors installed. nock.cleanAll() only removes mock expectations, and @tufjs/repo-mock pulls in a second copy of nock (v14) that patches requests through MSW. When the network suite lands in a worker that already ran those suites, requests meant for the local test server get intercepted, which produces Nock: No match for request, No socket was returned in the connect() function, and 5-second timeouts.

Changes

  • Run network.test.ts as a separate oci-network Jest project. Its runner always uses a worker process, even with --runInBand, so the suite never shares a process with other suites.
  • Call nock.restore() around the real-transport block so this suite's own nock instance doesn't intercept real connections.
  • Match the setup file's test path against both / and \ so proxy environment variables are cleared on Windows.
  • Assert the expected 403 from the test proxy instead of swallowing errors, so a failed connection surfaces directly rather than as an empty connects array.
  • Document the dedicated test project in the OCI README.

No production code changes.

Testing

I reproduced the failure locally with jest --runInBand --coverage --cache=false and confirmed the fix with full-suite runs (99 suites, 902 tests) on Node 22.22.2 and 24.15.0, using both --runInBand and the CI --maxWorkers=2 settings. I also ran the network project with HTTPS_PROXY, HTTP_PROXY, and NO_PROXY set in the environment.

The real-transport tests in network.test.ts fail intermittently in the
full suite. Other suites leave process-wide HTTP interceptors installed
(nock.cleanAll() only clears expectations, and a second nock copy pulled
in by @tufjs/repo-mock patches requests through MSW), so requests that
should hit the local test server are intercepted instead.

Run network.test.ts as a separate `oci-network` Jest project with a
runner that always uses a worker process, even under --runInBand.
Also restore nock for the real-transport block, match the setup file's
test path on Windows separators, and assert the expected 403 proxy
response rather than swallowing errors.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Brian DeHamer <bdehamer@github.com>
@bdehamer
bdehamer requested a review from a team as a code owner October 29, 2026 22:21
@changeset-bot

changeset-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6382af7

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

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