test(node-fetch): re-enable the set-cookie header combining test - #5730
Open
pacocartones wants to merge 1 commit into
Open
test(node-fetch): re-enable the set-cookie header combining test#5730pacocartones wants to merge 1 commit into
pacocartones wants to merge 1 commit into
Conversation
`should allow get all responses of a header` has been skipped since 7e085e0 ("fix(test): fix test skipping logic", nodejs#1216, 2022-02-09). The reason was that at the time `fetch` stripped `set-cookie` from response headers, so `res.headers.get('set-cookie')` returned `null` instead of the combined `a=1, b=1`. That was fixed three months later by bf6d5a1 ("feat: remove headers filtering", nodejs#1469, fixes nodejs#1262), which removed the forbidden-response- header filtering from `filterResponse`. Checked against both sides of that commit with a small probe against a server sending `Set-Cookie: ['a=1', 'b=1']`: at 0e64274 `get('set-cookie')` is `null`, at bf6d5a1 it is `'a=1, b=1'`. The test has been passing ever since, but the skip was never removed. The assertion still exercises the library, not a constant: making `HeadersList.append` keep only the first `set-cookie` instead of combining makes it fail with `'a=1' !== 'a=1, b=1'`. The other five `it.skip`s in this file are left as they are. They use the chai-era `expect(...).to.timeout` global, which no longer exists under `node:test` (`ReferenceError: expect is not defined`), so they need a rewrite rather than an unskip. Signed-off-by: Paco Cartones <pacocartones@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5730 +/- ##
==========================================
- Coverage 93.47% 93.46% -0.01%
==========================================
Files 110 110
Lines 38908 38908
==========================================
- Hits 36368 36365 -3
- Misses 2540 2543 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This relates to...
Nothing open. It removes an
it.skipintest/node-fetch/main.jsthat has outlived its cause by about four years.Rationale
should allow get all responses of a headerwas skipped in 7e085e0 (#1216, 2022-02-09) with a bare// TODO: fix test.. The reason it was failing is visible in the diff of that commit: it asserts that a response carrying twoSet-Cookieheaders exposes them combined,and at that point
filterResponse()dropped every forbidden response-header name —set-cookieincluded — from basic responses, soget('set-cookie')wasnull.That filtering was removed three months later in bf6d5a1 (#1469, "feat: remove headers filtering", fixes #1262 / #1463). The test has been able to pass ever since; only the skip stayed behind.
Checked on both sides of that commit, with a small script driving a server that sends
Set-Cookie: ['a=1', 'b=1']:The assertion is still meaningful. A test that passes is not automatically a test that still checks something, so I broke the behaviour on purpose to confirm it is not vacuous. Making
HeadersList.appendinlib/web/fetch/headers.jskeep only the firstset-cookieinstead of combining, with the test file untouched:So it exercises the real header-combining path, and it fails when that path regresses.
Order-independence: it passes on its own (
--test-name-pattern, 3/3) and inside the whole file (3/3).On the other five skips in this file: they are left alone deliberately. All five use the chai-era
expect(...).to.timeoutglobal under/* global expect */; there is no such global undernode:test, so unskipping one just givesReferenceError: expect is not definedatmain.js:1468. They need a rewrite against the current runner, not an unskip, and that does not belong in this PR.Changes
test/node-fetch/main.js:it.skip→itforshould allow get all responses of a header, and the stale// TODO: fix test.above it removed. No source changes.Before (
node --test test/node-fetch/main.js):After:
npm run test:node-fetchon the branch:tests 189 / pass 177 / fail 0 / skipped 12, exit code 0.npm run lintpasses.Features
N/A
Bug Fixes
N/A
Breaking Changes and Deprecations
N/A
Status