@nuxt/test-utils 3.19.2 → 3.21.0
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/config.d.mts +3 -3
- package/dist/config.mjs +13 -39
- package/dist/e2e.d.mts +2 -2
- package/dist/e2e.mjs +8 -4
- package/dist/experimental.mjs +1 -1
- package/dist/module.mjs +25 -15
- package/dist/playwright.d.mts +1 -1
- package/dist/playwright.mjs +7 -3
- package/dist/runtime/global-setup.mjs +3 -4
- package/dist/runtime/shared/environment.mjs +34 -12
- package/dist/runtime-utils/index.d.mts +48 -12
- package/dist/runtime-utils/index.mjs +163 -155
- package/dist/shared/{test-utils.DtJCg4f3.d.mts → test-utils.20kU0tZa.d.mts} +11 -11
- package/dist/shared/{test-utils.CT3RJOY3.mjs → test-utils.3NR-so9-.mjs} +10 -9
- package/dist/shared/{test-utils.B8qEdk9k.mjs → test-utils.CtwoJP76.mjs} +1 -1
- package/dist/shared/test-utils.G1ew4kEe.mjs +67 -0
- package/dist/vitest-environment.mjs +54 -22
- package/package.json +54 -61
|
@@ -41,24 +41,46 @@ async function setupWindow(win, environmentOptions) {
|
|
|
41
41
|
app.id = rootId;
|
|
42
42
|
win.document.body.appendChild(app);
|
|
43
43
|
const h3App = createApp();
|
|
44
|
-
if (!win.fetch) {
|
|
44
|
+
if (!win.fetch || !("Request" in win)) {
|
|
45
45
|
await import('node-fetch-native/polyfill');
|
|
46
46
|
win.URLSearchParams = globalThis.URLSearchParams;
|
|
47
|
+
win.Request ??= class Request extends globalThis.Request {
|
|
48
|
+
constructor(input, init) {
|
|
49
|
+
if (typeof input === "string") {
|
|
50
|
+
super(new URL(input, win.location.origin), init);
|
|
51
|
+
} else {
|
|
52
|
+
super(input, init);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
47
56
|
}
|
|
48
57
|
const nodeHandler = toNodeListener(h3App);
|
|
49
58
|
const registry = /* @__PURE__ */ new Set();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
const _fetch = fetch;
|
|
60
|
+
win.fetch = async (input, _init) => {
|
|
61
|
+
let url;
|
|
62
|
+
let init = _init;
|
|
63
|
+
if (typeof input === "string") {
|
|
64
|
+
url = input;
|
|
65
|
+
} else if (input instanceof URL) {
|
|
66
|
+
url = input.toString();
|
|
67
|
+
} else {
|
|
68
|
+
url = input.url;
|
|
69
|
+
init = {
|
|
70
|
+
method: init?.method ?? input.method,
|
|
71
|
+
body: init?.body ?? input.body,
|
|
72
|
+
headers: init?.headers ?? input.headers
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const base = url.split("?")[0];
|
|
76
|
+
if (registry.has(base) || registry.has(url)) {
|
|
77
|
+
url = "/_" + url;
|
|
60
78
|
}
|
|
61
|
-
|
|
79
|
+
if (url.startsWith("/")) {
|
|
80
|
+
const response = await fetchNodeRequestHandler(nodeHandler, url, init);
|
|
81
|
+
return normalizeFetchResponse(response);
|
|
82
|
+
}
|
|
83
|
+
return _fetch(input, _init);
|
|
62
84
|
};
|
|
63
85
|
win.$fetch = createFetch({ fetch: win.fetch, Headers: win.Headers });
|
|
64
86
|
win.__registry = registry;
|
|
@@ -150,10 +172,11 @@ const jsdom = (async function(global, { jsdom = {} }) {
|
|
|
150
172
|
console: false,
|
|
151
173
|
cookieJar: false
|
|
152
174
|
});
|
|
175
|
+
const virtualConsole = jsdomOptions.console && global.console ? new VirtualConsole() : void 0;
|
|
153
176
|
const window = new JSDOM(jsdomOptions.html, {
|
|
154
177
|
...jsdomOptions,
|
|
155
178
|
resources: jsdomOptions.resources ?? (jsdomOptions.userAgent ? new ResourceLoader({ userAgent: jsdomOptions.userAgent }) : void 0),
|
|
156
|
-
virtualConsole:
|
|
179
|
+
virtualConsole: virtualConsole ? "sendTo" in virtualConsole ? virtualConsole.sendTo(global.console) : virtualConsole.forwardTo(global.console) : void 0,
|
|
157
180
|
cookieJar: jsdomOptions.cookieJar ? new CookieJar() : void 0
|
|
158
181
|
}).window;
|
|
159
182
|
window.scrollTo = () => {
|
|
@@ -161,6 +184,7 @@ const jsdom = (async function(global, { jsdom = {} }) {
|
|
|
161
184
|
return {
|
|
162
185
|
window,
|
|
163
186
|
teardown() {
|
|
187
|
+
window.close();
|
|
164
188
|
}
|
|
165
189
|
};
|
|
166
190
|
});
|
|
@@ -184,21 +208,15 @@ const index = {
|
|
|
184
208
|
jsdom: { url }
|
|
185
209
|
}));
|
|
186
210
|
if (environmentOptions?.nuxt?.mock?.intersectionObserver) {
|
|
187
|
-
win.IntersectionObserver
|
|
188
|
-
observe() {
|
|
189
|
-
}
|
|
190
|
-
unobserve() {
|
|
191
|
-
}
|
|
192
|
-
disconnect() {
|
|
193
|
-
}
|
|
194
|
-
};
|
|
211
|
+
win.IntersectionObserver ||= IntersectionObserver;
|
|
195
212
|
}
|
|
196
213
|
if (environmentOptions?.nuxt?.mock?.indexedDb) {
|
|
197
214
|
win.indexedDB = indexedDB;
|
|
198
215
|
}
|
|
199
216
|
const teardownWindow = await setupWindow(win, environmentOptions);
|
|
200
217
|
const { keys, originals } = populateGlobal(global, win, {
|
|
201
|
-
bindFunctions: true
|
|
218
|
+
bindFunctions: true,
|
|
219
|
+
additionalKeys: ["fetch", "Request"]
|
|
202
220
|
});
|
|
203
221
|
return {
|
|
204
222
|
// called after all tests with this env have been run
|
|
@@ -206,10 +224,24 @@ const index = {
|
|
|
206
224
|
keys.forEach((key) => delete global[key]);
|
|
207
225
|
teardownWindow();
|
|
208
226
|
originals.forEach((v, k) => global[k] = v);
|
|
227
|
+
if (!global.IntersectionObserver) {
|
|
228
|
+
global.IntersectionObserver = IntersectionObserver;
|
|
229
|
+
}
|
|
209
230
|
teardown();
|
|
210
231
|
}
|
|
211
232
|
};
|
|
212
233
|
}
|
|
213
234
|
};
|
|
235
|
+
class IntersectionObserver {
|
|
236
|
+
observe() {
|
|
237
|
+
}
|
|
238
|
+
unobserve() {
|
|
239
|
+
}
|
|
240
|
+
disconnect() {
|
|
241
|
+
}
|
|
242
|
+
takeRecords() {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
}
|
|
214
246
|
|
|
215
247
|
export { index as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/test-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/test-utils.git"
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"scripts": {
|
|
57
57
|
"lint": "eslint .",
|
|
58
58
|
"lint:fix": "eslint . --fix",
|
|
59
|
+
"test": "pnpm test:types && pnpm test:unit && pnpm test:examples",
|
|
59
60
|
"test:examples": "pnpm --filter '!example-app-cucumber' --filter '!example-app-jest' -r test && pnpm --filter example-app-cucumber -r test",
|
|
60
61
|
"test:knip": "knip",
|
|
61
62
|
"test:engines": "pnpm installed-check --no-workspaces --ignore-dev",
|
|
@@ -66,72 +67,73 @@
|
|
|
66
67
|
"dev:prepare": "nuxt prepare && unbuild --stub && pnpm -r dev:prepare"
|
|
67
68
|
},
|
|
68
69
|
"dependencies": {
|
|
69
|
-
"@nuxt/kit": "^3.
|
|
70
|
-
"c12": "^3.
|
|
70
|
+
"@nuxt/kit": "^3.20.1",
|
|
71
|
+
"c12": "^3.3.2",
|
|
71
72
|
"consola": "^3.4.2",
|
|
72
73
|
"defu": "^6.1.4",
|
|
73
74
|
"destr": "^2.0.5",
|
|
74
75
|
"estree-walker": "^3.0.3",
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"node-
|
|
82
|
-
"
|
|
76
|
+
"exsolve": "^1.0.8",
|
|
77
|
+
"fake-indexeddb": "^6.2.5",
|
|
78
|
+
"get-port-please": "^3.2.0",
|
|
79
|
+
"h3": "^1.15.4",
|
|
80
|
+
"local-pkg": "^1.1.2",
|
|
81
|
+
"magic-string": "^0.30.21",
|
|
82
|
+
"node-fetch-native": "^1.6.7",
|
|
83
|
+
"node-mock-http": "^1.0.3",
|
|
84
|
+
"ofetch": "^1.5.1",
|
|
83
85
|
"pathe": "^2.0.3",
|
|
84
|
-
"perfect-debounce": "^
|
|
86
|
+
"perfect-debounce": "^2.0.0",
|
|
85
87
|
"radix3": "^1.1.2",
|
|
86
88
|
"scule": "^1.3.0",
|
|
87
|
-
"std-env": "^3.
|
|
88
|
-
"tinyexec": "^1.0.
|
|
89
|
+
"std-env": "^3.10.0",
|
|
90
|
+
"tinyexec": "^1.0.2",
|
|
89
91
|
"ufo": "^1.6.1",
|
|
90
|
-
"unplugin": "^2.3.
|
|
92
|
+
"unplugin": "^2.3.11",
|
|
91
93
|
"vitest-environment-nuxt": "^1.0.1",
|
|
92
|
-
"vue": "^3.5.
|
|
94
|
+
"vue": "^3.5.25"
|
|
93
95
|
},
|
|
94
96
|
"devDependencies": {
|
|
95
|
-
"@cucumber/cucumber": "
|
|
96
|
-
"@jest/globals": "30.0
|
|
97
|
-
"@nuxt/devtools-kit": "2.
|
|
98
|
-
"@nuxt/eslint-config": "1.
|
|
99
|
-
"@nuxt/schema": "
|
|
100
|
-
"@playwright/test": "1.
|
|
97
|
+
"@cucumber/cucumber": "12.3.0",
|
|
98
|
+
"@jest/globals": "30.2.0",
|
|
99
|
+
"@nuxt/devtools-kit": "2.7.0",
|
|
100
|
+
"@nuxt/eslint-config": "1.11.0",
|
|
101
|
+
"@nuxt/schema": "4.2.1",
|
|
102
|
+
"@playwright/test": "1.57.0",
|
|
101
103
|
"@testing-library/vue": "8.1.0",
|
|
102
|
-
"@types/bun": "1.
|
|
104
|
+
"@types/bun": "1.3.3",
|
|
103
105
|
"@types/estree": "1.0.8",
|
|
104
|
-
"@types/jsdom": "
|
|
106
|
+
"@types/jsdom": "27.0.0",
|
|
105
107
|
"@types/node": "latest",
|
|
106
|
-
"@types/semver": "7.7.
|
|
108
|
+
"@types/semver": "7.7.1",
|
|
107
109
|
"@vue/test-utils": "2.4.6",
|
|
108
|
-
"changelogen": "0.6.
|
|
110
|
+
"changelogen": "0.6.2",
|
|
109
111
|
"compatx": "0.2.0",
|
|
110
|
-
"eslint": "9.
|
|
112
|
+
"eslint": "9.39.1",
|
|
111
113
|
"installed-check": "9.3.0",
|
|
112
|
-
"knip": "5.
|
|
113
|
-
"nitropack": "2.
|
|
114
|
-
"nuxt": "
|
|
115
|
-
"pkg-pr-new": "0.0.
|
|
116
|
-
"playwright-core": "1.
|
|
117
|
-
"rollup": "4.
|
|
118
|
-
"semver": "7.7.
|
|
119
|
-
"typescript": "5.
|
|
114
|
+
"knip": "5.71.0",
|
|
115
|
+
"nitropack": "2.12.9",
|
|
116
|
+
"nuxt": "4.2.1",
|
|
117
|
+
"pkg-pr-new": "0.0.62",
|
|
118
|
+
"playwright-core": "1.57.0",
|
|
119
|
+
"rollup": "4.53.3",
|
|
120
|
+
"semver": "7.7.3",
|
|
121
|
+
"typescript": "5.9.3",
|
|
120
122
|
"unbuild": "latest",
|
|
121
|
-
"unimport": "5.
|
|
122
|
-
"vite": "7.
|
|
123
|
+
"unimport": "5.5.0",
|
|
124
|
+
"vite": "7.2.6",
|
|
123
125
|
"vitest": "3.2.4",
|
|
124
|
-
"vue-router": "4.
|
|
125
|
-
"vue-tsc": "
|
|
126
|
+
"vue-router": "4.6.3",
|
|
127
|
+
"vue-tsc": "3.1.5"
|
|
126
128
|
},
|
|
127
129
|
"peerDependencies": {
|
|
128
|
-
"@cucumber/cucumber": "^10.3.1 ||
|
|
129
|
-
"@jest/globals": "^29.5.0 ||
|
|
130
|
+
"@cucumber/cucumber": "^10.3.1 || >=11.0.0",
|
|
131
|
+
"@jest/globals": "^29.5.0 || >=30.0.0",
|
|
130
132
|
"@playwright/test": "^1.43.1",
|
|
131
133
|
"@testing-library/vue": "^7.0.0 || ^8.0.1",
|
|
132
134
|
"@vue/test-utils": "^2.4.2",
|
|
133
|
-
"happy-dom": "
|
|
134
|
-
"jsdom": "
|
|
135
|
+
"happy-dom": "*",
|
|
136
|
+
"jsdom": "*",
|
|
135
137
|
"playwright-core": "^1.43.1",
|
|
136
138
|
"vitest": "^3.2.0"
|
|
137
139
|
},
|
|
@@ -168,27 +170,18 @@
|
|
|
168
170
|
}
|
|
169
171
|
},
|
|
170
172
|
"resolutions": {
|
|
171
|
-
"@cucumber/cucumber": "
|
|
172
|
-
"@nuxt/
|
|
173
|
-
"@nuxt/schema": "^3.17.5",
|
|
173
|
+
"@cucumber/cucumber": "12.3.0",
|
|
174
|
+
"@nuxt/schema": "4.2.1",
|
|
174
175
|
"@nuxt/test-utils": "workspace:*",
|
|
175
|
-
"@types/node": "
|
|
176
|
-
"rollup": "4.
|
|
177
|
-
"vite": "7.
|
|
178
|
-
"vite-node": "
|
|
176
|
+
"@types/node": "24.10.1",
|
|
177
|
+
"rollup": "4.53.3",
|
|
178
|
+
"vite": "7.2.6",
|
|
179
|
+
"vite-node": "5.2.0",
|
|
179
180
|
"vitest": "3.2.4",
|
|
180
|
-
"vue": "^3.5.
|
|
181
|
+
"vue": "^3.5.25"
|
|
181
182
|
},
|
|
182
183
|
"engines": {
|
|
183
|
-
"node": "^
|
|
184
|
+
"node": "^20.0.0 || ^22.0.0 || >=24.0.0"
|
|
184
185
|
},
|
|
185
|
-
"packageManager": "pnpm@10.
|
|
186
|
-
"pnpm": {
|
|
187
|
-
"onlyBuiltDependencies": [
|
|
188
|
-
"better-sqlite3"
|
|
189
|
-
],
|
|
190
|
-
"ignoredBuiltDependencies": [
|
|
191
|
-
"esbuild"
|
|
192
|
-
]
|
|
193
|
-
}
|
|
186
|
+
"packageManager": "pnpm@10.24.0"
|
|
194
187
|
}
|