Skip to content

test: expand shouldBypassProxy coverage for wildcard, IPv6, and edge cases#10723

Merged
jasonsaayman merged 2 commits intov1.xfrom
copilot/add-test-coverage-shouldbypassproxy
Apr 15, 2026
Merged

test: expand shouldBypassProxy coverage for wildcard, IPv6, and edge cases#10723
jasonsaayman merged 2 commits intov1.xfrom
copilot/add-test-coverage-shouldbypassproxy

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

shouldBypassProxy test coverage was missing several high-signal no_proxy scenarios (wildcard, bracketed IPv6 with ports, and malformed/empty inputs). This PR adds focused unit tests to cover those paths and lock expected behavior.

  • Coverage additions in tests/unit/helpers/shouldBypassProxy.test.js

    • Adds no_proxy='*' case to verify global bypass behavior across hostname types.
    • Adds bracketed IPv6 + explicit port matching ([::1]:8080) and non-matching port case.
    • Adds empty no_proxy behavior to ensure bypass is not triggered.
    • Adds malformed URL input behavior to ensure safe false return.
  • Wildcard and port-specific matching scenarios

    • Complements existing wildcard domain and explicit port tests with global wildcard behavior and IPv6 port-specific matching.
it('should support bracketed ipv6 with explicit port in no_proxy', () => {
  setNoProxy('[::1]:8080');

  expect(shouldBypassProxy('http://[::1]:8080/')).toBe(true);
  expect(shouldBypassProxy('http://[::1]:8081/')).toBe(false);
});

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • no-such-domain-987654.com
    • Triggering command: /opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/axios/axios/node_modules/vitest/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/axios/axios/node_modules/vitest/dist/workers/forks.js (dns block)
  • notexistsurl.in.nowhere
    • Triggering command: /opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/axios/axios/node_modules/vitest/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/axios/axios/node_modules/vitest/dist/workers/forks.js (dns block)
  • postman-echo.com
    • Triggering command: /opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node --experimental-import-meta-resolve --require /home/REDACTED/work/axios/axios/node_modules/vitest/suppress-warnings.cjs --conditions node --conditions development /home/REDACTED/work/axios/axios/node_modules/vitest/dist/workers/forks.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"The test file lacks comprehensive test coverage for the `shouldBypassProxy` function. Key missing scenarios include: wildcard matching (e.g., `*.example.com`), IPv6 address handling with brackets in `no_proxy`, port-specific matching, and edge cases like empty or malformed URLs. Consider adding tests for: IPv6 with explicit ports in `no_proxy` (e.g., `[::1]:8080`), wildcard subdomain matching, and behavior when `no_proxy` is set to `*`.","fixFiles":[{"filePath":"tests/unit/helpers/shouldBypassProxy.test.js","diff":"diff --git a/tests/unit/helpers/shouldBypassProxy.test.js b/tests/unit/helpers/shouldBypassProxy.test.js\n--- a/tests/unit/helpers/shouldBypassProxy.test.js\n+++ b/tests/unit/helpers/shouldBypassProxy.test.js\n@@ -73,4 +73,31 @@\n     expect(shouldBypassProxy('http://localhost:8080/')).toBe(true);\n     expect(shouldBypassProxy('http://localhost:8081/')).toBe(false);\n   });\n+\n+  it('should bypass proxy for any host when no_proxy is *', () => {\n+    setNoProxy('*');\n+\n+    expect(shouldBypassProxy('http://example.com/')).toBe(true);\n+    expect(shouldBypassProxy('http://localhost:1234/')).toBe(true);\n+    expect(shouldBypassProxy('http://[::1]:8080/')).toBe(true);\n+  });\n+\n+  it('should support bracketed ipv6 with explicit port in no_proxy', () => {\n+    setNoProxy('[::1]:8080');\n+\n+    expect(shouldBypassProxy('http://[::1]:8080/')).toBe(true);\n+    expect(shouldBypassProxy('http://[::1]:8081/')).toBe(false);\n+  });\n+\n+  it('should not bypass when no_proxy is empty', () => {\n+    setNoProxy('');\n+\n+    expect(shouldBypassProxy('http://localhost:8080/')).toBe(false);\n+  });\n+\n+  it('should not bypass for malformed URLs', () => {\n+    setNoProxy('localhost,127.0.0.1,::1');\n+\n+    expect(shouldBypassProxy('not a url')).toBe(false);\n+  });\n });\n"}]}]

Copilot AI changed the title [WIP] Add comprehensive test coverage for shouldBypassProxy function test: expand shouldBypassProxy coverage for wildcard, IPv6, and edge cases Apr 15, 2026
Copilot AI requested a review from jasonsaayman April 15, 2026 17:27
@jasonsaayman jasonsaayman added priority::medium A medium priority commit::fix The PR is related to a bugfix labels Apr 15, 2026
@jasonsaayman jasonsaayman marked this pull request as ready for review April 15, 2026 17:57
@jasonsaayman jasonsaayman merged commit 0e1634a into v1.x Apr 15, 2026
22 checks passed
@jasonsaayman jasonsaayman deleted the copilot/add-test-coverage-shouldbypassproxy branch April 15, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit::fix The PR is related to a bugfix priority::medium A medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants