Skip to content

fix(spec-parser): add missing stubs in remote reference unit test#16171

Draft
Copilot wants to merge 2 commits into
devfrom
copilot/fix-unit-test-failure
Draft

fix(spec-parser): add missing stubs in remote reference unit test#16171
Copilot wants to merge 2 commits into
devfrom
copilot/fix-unit-test-failure

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

The unit test SpecParser > validate > should return an error result object if contain remote reference was failing with AssertionError: expected 'spec-not-valid' to equal 'remote-ref-not-supported'.

Root cause: The test only stubbed parser.validate but left parser.parse, parser.dereference, and parser.$refs.paths unstubbed. At test runtime, dereference() made a real network request to resolve the remote $ref URL, failed, and the catch block returned ErrorType.SpecNotValid before execution ever reached the refPaths.length > 1 guard that emits ErrorType.RemoteRefNotSupported.

Fix: Added the three missing stubs, consistent with every other test in the same suite and the equivalent browser test:

sinon.stub(specParser.parser, "parse").resolves(spec as any);
sinon.stub(specParser.parser, "dereference").resolves(spec as any);
sinon
  .stub(specParser.parser.$refs, "paths")
  .returns(["localPath", "https://petstore3.swagger.io/api/v3/openapi.json"]);

The $refs.paths stub returns two entries (local + remote) so the > 1 check fires and the correct error type is produced.

Copilot AI changed the title [WIP] Fix failing GitHub Actions job 'unit-test' fix(spec-parser): add missing stubs in remote reference unit test Jun 17, 2026
Copilot AI requested a review from HuihuiWu-Microsoft June 17, 2026 07:22
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.

2 participants