@nuxt/test-utils 3.17.1 → 3.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vitest-environment.mjs +44 -15
- package/package.json +24 -24
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createFetch
|
|
1
|
+
import { createFetch } from 'ofetch';
|
|
2
2
|
import { indexedDB } from 'fake-indexeddb';
|
|
3
3
|
import { joinURL } from 'ufo';
|
|
4
|
-
import { createApp, toNodeListener, defineEventHandler } from 'h3';
|
|
4
|
+
import { createApp, toNodeListener, defineEventHandler, splitCookiesString } from 'h3';
|
|
5
5
|
import defu from 'defu';
|
|
6
6
|
import { toRouteMatcher, createRouter, exportMatcher } from 'radix3';
|
|
7
7
|
import { populateGlobal } from 'vitest/environments';
|
|
8
|
-
import {
|
|
8
|
+
import { fetchNodeRequestHandler } from 'node-mock-http';
|
|
9
9
|
import { importModule } from 'local-pkg';
|
|
10
10
|
|
|
11
11
|
const happyDom = (async function(_, { happyDom = {} }) {
|
|
@@ -103,22 +103,22 @@ const index = {
|
|
|
103
103
|
await import('node-fetch-native/polyfill');
|
|
104
104
|
win.URLSearchParams = globalThis.URLSearchParams;
|
|
105
105
|
}
|
|
106
|
-
const
|
|
107
|
-
const localFetch = createFetch(localCall, win.fetch);
|
|
106
|
+
const nodeHandler = toNodeListener(h3App);
|
|
108
107
|
const registry = /* @__PURE__ */ new Set();
|
|
109
|
-
win.fetch = (
|
|
110
|
-
if (typeof
|
|
111
|
-
const base =
|
|
112
|
-
if (registry.has(base) || registry.has(
|
|
113
|
-
|
|
108
|
+
win.fetch = async (url2, init) => {
|
|
109
|
+
if (typeof url2 === "string") {
|
|
110
|
+
const base = url2.split("?")[0];
|
|
111
|
+
if (registry.has(base) || registry.has(url2)) {
|
|
112
|
+
url2 = "/_" + url2;
|
|
113
|
+
}
|
|
114
|
+
if (url2.startsWith("/")) {
|
|
115
|
+
const response = await fetchNodeRequestHandler(nodeHandler, url2, init);
|
|
116
|
+
return normalizeFetchResponse(response);
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
|
-
return
|
|
117
|
-
...options,
|
|
118
|
-
headers: Array.isArray(options?.headers) ? new Headers(options?.headers) : options?.headers
|
|
119
|
-
});
|
|
119
|
+
return fetch(url2, init);
|
|
120
120
|
};
|
|
121
|
-
win.$fetch = createFetch
|
|
121
|
+
win.$fetch = createFetch({ fetch: win.fetch, Headers: win.Headers });
|
|
122
122
|
win.__registry = registry;
|
|
123
123
|
win.__app = h3App;
|
|
124
124
|
const { keys, originals } = populateGlobal(global, win, {
|
|
@@ -165,5 +165,34 @@ const index = {
|
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
+
function normalizeFetchResponse(response) {
|
|
169
|
+
if (!response.headers.has("set-cookie")) {
|
|
170
|
+
return response;
|
|
171
|
+
}
|
|
172
|
+
return new Response(response.body, {
|
|
173
|
+
status: response.status,
|
|
174
|
+
statusText: response.statusText,
|
|
175
|
+
headers: normalizeCookieHeaders(response.headers)
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function normalizeCookieHeader(header = "") {
|
|
179
|
+
return splitCookiesString(joinHeaders(header));
|
|
180
|
+
}
|
|
181
|
+
function normalizeCookieHeaders(headers) {
|
|
182
|
+
const outgoingHeaders = new Headers();
|
|
183
|
+
for (const [name, header] of headers) {
|
|
184
|
+
if (name === "set-cookie") {
|
|
185
|
+
for (const cookie of normalizeCookieHeader(header)) {
|
|
186
|
+
outgoingHeaders.append("set-cookie", cookie);
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
outgoingHeaders.set(name, joinHeaders(header));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return outgoingHeaders;
|
|
193
|
+
}
|
|
194
|
+
function joinHeaders(value) {
|
|
195
|
+
return Array.isArray(value) ? value.join(", ") : String(value);
|
|
196
|
+
}
|
|
168
197
|
|
|
169
198
|
export { index as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/test-utils",
|
|
3
|
-
"version": "3.17.
|
|
3
|
+
"version": "3.17.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/test-utils.git"
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"dev:prepare": "nuxi prepare && unbuild --stub && pnpm -r dev:prepare"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@nuxt/kit": "^3.
|
|
67
|
-
"@nuxt/schema": "^3.
|
|
66
|
+
"@nuxt/kit": "^3.16.0",
|
|
67
|
+
"@nuxt/schema": "^3.16.0",
|
|
68
68
|
"c12": "^3.0.2",
|
|
69
69
|
"consola": "^3.4.0",
|
|
70
70
|
"defu": "^6.1.4",
|
|
@@ -73,50 +73,50 @@
|
|
|
73
73
|
"fake-indexeddb": "^6.0.0",
|
|
74
74
|
"get-port-please": "^3.1.2",
|
|
75
75
|
"h3": "^1.15.1",
|
|
76
|
-
"local-pkg": "^1.1.
|
|
76
|
+
"local-pkg": "^1.1.1",
|
|
77
77
|
"magic-string": "^0.30.17",
|
|
78
78
|
"node-fetch-native": "^1.6.5",
|
|
79
|
+
"node-mock-http": "^1.0.0",
|
|
79
80
|
"ofetch": "^1.4.1",
|
|
80
81
|
"pathe": "^2.0.3",
|
|
81
82
|
"perfect-debounce": "^1.0.0",
|
|
82
83
|
"radix3": "^1.1.2",
|
|
83
84
|
"scule": "^1.3.0",
|
|
84
|
-
"std-env": "^3.8.
|
|
85
|
+
"std-env": "^3.8.1",
|
|
85
86
|
"tinyexec": "^0.3.2",
|
|
86
87
|
"ufo": "^1.5.4",
|
|
87
|
-
"unenv": "^1.10.0",
|
|
88
88
|
"unplugin": "^2.2.0",
|
|
89
|
-
"vite": "^6.2.
|
|
89
|
+
"vite": "^6.2.1",
|
|
90
90
|
"vitest-environment-nuxt": "^1.0.1",
|
|
91
91
|
"vue": "^3.5.13"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@cucumber/cucumber": "11.2.0",
|
|
95
95
|
"@jest/globals": "29.7.0",
|
|
96
|
-
"@nuxt/devtools-kit": "2.
|
|
96
|
+
"@nuxt/devtools-kit": "2.2.1",
|
|
97
97
|
"@nuxt/eslint-config": "1.1.0",
|
|
98
|
-
"@playwright/test": "1.
|
|
98
|
+
"@playwright/test": "1.51.0",
|
|
99
99
|
"@testing-library/vue": "8.1.0",
|
|
100
100
|
"@types/estree": "1.0.6",
|
|
101
101
|
"@types/jsdom": "21.1.7",
|
|
102
|
-
"@types/node": "22.13.
|
|
102
|
+
"@types/node": "22.13.10",
|
|
103
103
|
"@types/semver": "7.5.8",
|
|
104
104
|
"@vue/test-utils": "2.4.6",
|
|
105
|
-
"changelogen": "0.6.
|
|
105
|
+
"changelogen": "0.6.1",
|
|
106
106
|
"compatx": "0.1.8",
|
|
107
|
-
"eslint": "9.
|
|
107
|
+
"eslint": "9.22.0",
|
|
108
108
|
"installed-check": "9.3.0",
|
|
109
109
|
"knip": "5.45.0",
|
|
110
|
-
"nitropack": "2.
|
|
111
|
-
"nuxt": "3.
|
|
110
|
+
"nitropack": "2.11.5",
|
|
111
|
+
"nuxt": "3.16.0",
|
|
112
112
|
"pkg-pr-new": "0.0.40",
|
|
113
|
-
"playwright-core": "1.
|
|
114
|
-
"rollup": "4.
|
|
113
|
+
"playwright-core": "1.51.0",
|
|
114
|
+
"rollup": "4.35.0",
|
|
115
115
|
"semver": "7.7.1",
|
|
116
116
|
"typescript": "5.8.2",
|
|
117
117
|
"unbuild": "latest",
|
|
118
118
|
"unimport": "4.1.2",
|
|
119
|
-
"vitest": "3.0.
|
|
119
|
+
"vitest": "3.0.8",
|
|
120
120
|
"vue-router": "4.5.0",
|
|
121
121
|
"vue-tsc": "2.2.8"
|
|
122
122
|
},
|
|
@@ -166,19 +166,19 @@
|
|
|
166
166
|
"resolutions": {
|
|
167
167
|
"@cucumber/cucumber": "11.2.0",
|
|
168
168
|
"@nuxt/devtools": "1.0.8",
|
|
169
|
-
"@nuxt/kit": "^3.
|
|
170
|
-
"@nuxt/schema": "^3.
|
|
169
|
+
"@nuxt/kit": "^3.16.0",
|
|
170
|
+
"@nuxt/schema": "^3.16.0",
|
|
171
171
|
"@nuxt/test-utils": "workspace:*",
|
|
172
|
-
"rollup": "4.
|
|
173
|
-
"vite": "^6.2.
|
|
174
|
-
"vite-node": "3.0.
|
|
175
|
-
"vitest": "3.0.
|
|
172
|
+
"rollup": "4.35.0",
|
|
173
|
+
"vite": "^6.2.1",
|
|
174
|
+
"vite-node": "3.0.8",
|
|
175
|
+
"vitest": "3.0.8",
|
|
176
176
|
"vue": "^3.5.13"
|
|
177
177
|
},
|
|
178
178
|
"engines": {
|
|
179
179
|
"node": "^18.20.5 || ^20.9.0 || ^22.0.0 || >=23.0.0"
|
|
180
180
|
},
|
|
181
|
-
"packageManager": "pnpm@10.
|
|
181
|
+
"packageManager": "pnpm@10.6.1",
|
|
182
182
|
"pnpm": {
|
|
183
183
|
"onlyBuiltDependencies": [
|
|
184
184
|
"better-sqlite3"
|