Skip to content

fix(test): assert the default Accept header on the parameters fetch - #182

Merged
soyuka merged 1 commit into
mainfrom
fix/parameters-test-default-accept
Sep 26, 2026
Merged

soyuka merged 1 commit into
mainfrom
fix/parameters-test-default-accept

Conversation

@vincentchalamon

Copy link
Copy Markdown
Contributor

The release workflow for v0.16.11 failed on Run tests, so 0.16.11 was tagged but never published to npm.

FAIL src/hydra/parseHydraDocumentation.test.ts > Resource parameters can be retrieved
AssertionError: expected last "spy" call to have been called with [ 'http://localhost/books', …(1) ]
- Expected
+ Received
  [
    "http://localhost/books",
    {
-     "headers": {},
+     "headers": Headers {},
    },
  ]

Cause

Two pull requests crossed, twenty seconds apart:

Commit Merged Change
57499c5 (#179) 08:17:50 adds the assertion, expecting a plain headers: {}
9738687 (#178) 08:18:10 makes setHeaders() always return a Headers instance carrying the default Accept

Before #178, setHeaders() short-circuited on a falsy options.headers and returned { ...options, headers: {} } with no Accept at all, which is exactly the bug #178 set out to fix. #179 was written against that behaviour.

Each run was green against main as it stood at the time, so neither CI saw the other. main has been red ever since.

Fix

Assert what both changes together are meant to guarantee: the parameters fetch targets the collection, and it carries the default Accept.

Comparing against a Headers instance is not a workable alternative. Headers exposes no enumerable own properties, so the matcher reports "Compared values have no visual difference" while still failing.

Verification

The release workflow fails on "Resource parameters can be retrieved":

    AssertionError: expected last "spy" call to have been called with
    [ 'http://localhost/books', …(1) ]
    -     "headers": {},
    +     "headers": Headers {},

Two pull requests crossed. #179 added the assertion expecting a plain
"headers: {}", and #178 merged twenty seconds later made setHeaders() always
build a Headers instance carrying the default Accept. Both were green against
main as it stood when each ran, so neither CI saw the other.

Assert what the two changes together are meant to guarantee: the parameters
fetch targets the collection and carries the default Accept header. Comparing
against a Headers instance is not an option, it has no enumerable own
properties and the matcher reports "no visual difference" while failing.
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 71.82% (🎯 70%) 311 / 433
🟢 Statements 71.78% (🎯 70%) 313 / 436
🟢 Functions 70.76% (🎯 70%) 46 / 65
🟢 Branches 60.64% (🎯 58%) 245 / 404
File CoverageNo changed files found.
Generated in workflow #327 for commit e080981 by the Vitest Coverage Report Action

@soyuka
soyuka merged commit a247d07 into main Sep 26, 2026
3 checks passed
@soyuka
soyuka deleted the fix/parameters-test-default-accept branch September 26, 2026 18:40
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