Skip to content

Commit 59f3ae8

Browse files
committed
chore: replace happy-dom with node environment in tests
1 parent a1d97e3 commit 59f3ae8

5 files changed

Lines changed: 22 additions & 57 deletions

File tree

package-lock.json

Lines changed: 19 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
"@typescript-eslint/parser": "^8.39.0",
9696
"@vitest/coverage-v8": "^4.1.8",
9797
"eslint": "^10.4.1",
98-
"happy-dom": "^20.9.0",
9998
"husky": "^9.1.7",
10099
"jsr": "^0.14.3",
101100
"lint-staged": "^17.0.5",

test/core/client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ describe('Retry-After header', () => {
461461
get: (name: string) => (name === 'Retry-After' ? '2' : undefined),
462462
},
463463
})
464-
const ctx = { attempt: 1, request: new Request('x'), response }
464+
const ctx = { attempt: 1, request: new Request('https://example.com'), response }
465465
const delay =
466466
typeof defaultDelay === 'function' ? defaultDelay(ctx) : defaultDelay
467467
expect(delay).toBe(2000)
@@ -480,7 +480,7 @@ describe('Retry-After header', () => {
480480
get: (name: string) => (name === 'Retry-After' ? date : undefined),
481481
},
482482
})
483-
const ctx = { attempt: 1, request: new Request('x'), response }
483+
const ctx = { attempt: 1, request: new Request('https://example.com'), response }
484484
const delay =
485485
typeof defaultDelay === 'function' ? defaultDelay(ctx) : defaultDelay
486486
expect(delay).toBe(5000)

test/integration/retry-post-body.integration.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
// @vitest-environment node
2-
// This test MUST run in the Node.js environment (not happy-dom) because only
3-
// Node.js/undici enforces the Fetch API spec rule that constructing a new Request
4-
// from an already-consumed Request throws:
5-
// "Cannot construct a Request with a Request object that has already been used."
6-
// happy-dom silently copies the body, masking the regression.
7-
81
import { createServer } from 'node:http'
92
import type { Server, IncomingMessage, ServerResponse } from 'node:http'
103
import { describe, it, expect, beforeAll, afterAll } from 'vitest'

vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { defineConfig } from 'vitest/config'
33
export default defineConfig({
44
test: {
55
globals: true,
6-
environment: 'happy-dom', // fetch in browser-like env
6+
environment: 'node',
77
coverage: {
88
reporter: ['text', 'lcov', 'html'],
99
exclude: ['coverage/**', 'dist/**', '**/*.config.*', '**/*.test.*'],

0 commit comments

Comments
 (0)