@nuxt/test-utils 3.21.0 → 3.22.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/README.md +1 -1
- package/dist/config.d.mts +2 -3
- package/dist/config.mjs +22 -20
- package/dist/e2e.d.mts +2 -2
- package/dist/e2e.mjs +17 -13
- package/dist/experimental.mjs +1 -1
- package/dist/module.mjs +271 -146
- package/dist/playwright.d.mts +1 -1
- package/dist/playwright.mjs +3 -3
- package/dist/runtime/shared/nuxt.d.ts +1 -1
- package/dist/runtime/shared/nuxt.mjs +10 -2
- package/dist/runtime/shared/vue-wrapper-plugin.d.ts +50 -0
- package/dist/runtime/shared/vue-wrapper-plugin.mjs +41 -0
- package/dist/runtime-utils/index.d.mts +24 -24
- package/dist/runtime-utils/index.mjs +157 -249
- package/dist/shared/{test-utils.G1ew4kEe.mjs → test-utils.BIY9XRkB.mjs} +1 -1
- package/dist/shared/{test-utils.CtwoJP76.mjs → test-utils.C_clWQBc.mjs} +4 -4
- package/dist/shared/{test-utils.3NR-so9-.mjs → test-utils.D2ZzXztg.mjs} +2 -2
- package/dist/shared/test-utils.DDUpsMYL.mjs +32 -0
- package/dist/shared/{test-utils.20kU0tZa.d.mts → test-utils.ZByFDqps.d.mts} +1 -1
- package/dist/vitest-wrapper/cli.d.mts +2 -0
- package/dist/vitest-wrapper/cli.mjs +78 -0
- package/package.json +25 -25
|
@@ -48,7 +48,7 @@ async function loadKit(rootDir) {
|
|
|
48
48
|
} catch (e) {
|
|
49
49
|
if (e.toString().includes("Cannot find module '@nuxt/kit'")) {
|
|
50
50
|
throw new Error(
|
|
51
|
-
"
|
|
51
|
+
"`@nuxt/test-utils` requires `@nuxt/kit` to be installed in your project. Try installing `nuxt` v3+ or `@nuxt/bridge` first."
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
throw e;
|
|
@@ -91,8 +91,8 @@ async function startServer(options = {}) {
|
|
|
91
91
|
PORT: String(port),
|
|
92
92
|
HOST: host,
|
|
93
93
|
NODE_ENV: "development",
|
|
94
|
-
...options.env,
|
|
95
|
-
...
|
|
94
|
+
...ctx.options.env,
|
|
95
|
+
...options.env
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
});
|
|
@@ -128,8 +128,8 @@ async function startServer(options = {}) {
|
|
|
128
128
|
PORT: String(port),
|
|
129
129
|
HOST: host,
|
|
130
130
|
NODE_ENV: "test",
|
|
131
|
-
...options.env,
|
|
132
|
-
...
|
|
131
|
+
...ctx.options.env,
|
|
132
|
+
...options.env
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { u as useTestContext, d as url, c as createTestContext, a as startServer, b as stopServer, s as setTestContext } from './test-utils.
|
|
1
|
+
import { u as useTestContext, d as url, c as createTestContext, a as startServer, b as stopServer, s as setTestContext } from './test-utils.C_clWQBc.mjs';
|
|
2
2
|
import { existsSync, promises } from 'node:fs';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { defu } from 'defu';
|
|
5
|
-
import { l as loadKit } from './test-utils.
|
|
5
|
+
import { l as loadKit } from './test-utils.BIY9XRkB.mjs';
|
|
6
6
|
|
|
7
7
|
async function createBrowser() {
|
|
8
8
|
const ctx = useTestContext();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function isMessage(message) {
|
|
2
|
+
return message !== null && typeof message === "object" && "type" in message && message.type !== null && typeof message.type === "string" && "payload" in message && message.payload !== null && typeof message.payload === "object";
|
|
3
|
+
}
|
|
4
|
+
function createVitestTestSummary() {
|
|
5
|
+
return {
|
|
6
|
+
failedCount: 0,
|
|
7
|
+
passedCount: 0,
|
|
8
|
+
totalCount: 0
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function sendMessageToHost(type, payload) {
|
|
12
|
+
process.send?.({ type, payload });
|
|
13
|
+
}
|
|
14
|
+
function listenHostMessages(listener) {
|
|
15
|
+
process.on("message", (message) => {
|
|
16
|
+
if (isMessage(message)) {
|
|
17
|
+
listener(message);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function sendMessageToCli(cli, type, payload) {
|
|
22
|
+
cli.send({ type, payload });
|
|
23
|
+
}
|
|
24
|
+
function listenCliMessages(cli, listener) {
|
|
25
|
+
cli.on("message", (message) => {
|
|
26
|
+
if (isMessage(message)) {
|
|
27
|
+
listener(message);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { listenHostMessages as a, sendMessageToHost as b, createVitestTestSummary as c, listenCliMessages as l, sendMessageToCli as s };
|
|
@@ -116,4 +116,4 @@ interface TestHooks {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export { $fetch as $, createBrowser as c, createPage as d, stopServer as e, fetch as f, getBrowser as g, startServer as s, url as u, waitForHydration as w };
|
|
119
|
-
export type { GotoOptions as G, NuxtPage as N, StartServerOptions as S, TestOptions as T,
|
|
119
|
+
export type { GotoOptions as G, NuxtPage as N, StartServerOptions as S, TestOptions as T, TestHooks as a, TestContext as b, TestRunner as h };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { importModule } from 'local-pkg';
|
|
2
|
+
import { getPort } from 'get-port-please';
|
|
3
|
+
import { a as listenHostMessages, b as sendMessageToHost } from '../shared/test-utils.DDUpsMYL.mjs';
|
|
4
|
+
|
|
5
|
+
function createCustomReporter(onVitestInit) {
|
|
6
|
+
let ctx = void 0;
|
|
7
|
+
function getVitestUiUrl() {
|
|
8
|
+
if (!ctx.config.ui) return void 0;
|
|
9
|
+
const protocol = ctx.vite.config.server.https ? "https:" : "http:";
|
|
10
|
+
const host = ctx.config.api.host || "localhost";
|
|
11
|
+
const port = ctx.config.api.port;
|
|
12
|
+
const uiBase = ctx.config.uiBase;
|
|
13
|
+
return `${protocol}//${host}:${port}${uiBase}`;
|
|
14
|
+
}
|
|
15
|
+
function toUpdatedResult() {
|
|
16
|
+
const files = ctx.state.getFiles();
|
|
17
|
+
return {
|
|
18
|
+
failedCount: files.filter((f) => f.result?.state === "fail").length ?? 0,
|
|
19
|
+
passedCount: files.filter((f) => f.result?.state === "pass").length ?? 0,
|
|
20
|
+
totalCount: files.length ?? 0
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function toFinishedResult() {
|
|
24
|
+
return toUpdatedResult();
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
onInit(_ctx) {
|
|
28
|
+
ctx = _ctx;
|
|
29
|
+
onVitestInit(ctx);
|
|
30
|
+
sendMessageToHost("started", { uiUrl: getVitestUiUrl() });
|
|
31
|
+
},
|
|
32
|
+
onTestRunStart() {
|
|
33
|
+
sendMessageToHost("updated", toUpdatedResult());
|
|
34
|
+
},
|
|
35
|
+
onTaskUpdate() {
|
|
36
|
+
sendMessageToHost("updated", toUpdatedResult());
|
|
37
|
+
},
|
|
38
|
+
onFinished() {
|
|
39
|
+
sendMessageToHost("finished", toFinishedResult());
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async function main() {
|
|
44
|
+
const {
|
|
45
|
+
apiPorts,
|
|
46
|
+
watchMode
|
|
47
|
+
} = await new Promise((resolve) => {
|
|
48
|
+
listenHostMessages(({ type, payload }) => {
|
|
49
|
+
if (type === "start") resolve(payload);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
const port = apiPorts ? await getPort({ ports: apiPorts }) : void 0;
|
|
53
|
+
const { startVitest } = await importModule("vitest/node");
|
|
54
|
+
const customReporter = createCustomReporter((vitest2) => {
|
|
55
|
+
listenHostMessages(async ({ type, payload }) => {
|
|
56
|
+
if (type === "stop") {
|
|
57
|
+
await vitest2.exit(payload.force);
|
|
58
|
+
process.exit();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
const vitest = await startVitest("test", [], watchMode ? {
|
|
63
|
+
passWithNoTests: true,
|
|
64
|
+
ui: true,
|
|
65
|
+
watch: true,
|
|
66
|
+
open: false,
|
|
67
|
+
api: { port }
|
|
68
|
+
} : { ui: false, watch: false }, {
|
|
69
|
+
test: {
|
|
70
|
+
reporters: ["default", customReporter]
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
if (!watchMode) {
|
|
74
|
+
await vitest.exit();
|
|
75
|
+
process.exit();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/test-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/test-utils.git"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"lint": "eslint .",
|
|
58
58
|
"lint:fix": "eslint . --fix",
|
|
59
59
|
"test": "pnpm test:types && pnpm test:unit && pnpm test:examples",
|
|
60
|
-
"test:examples": "pnpm --filter '!example-app-cucumber' --filter '!example-app-jest' -r test && pnpm --filter example-app-cucumber -r test",
|
|
60
|
+
"test:examples": "pnpm --filter '!example-app-cucumber' --filter '!example-app-jest' --filter '!example-app-bun' -r test && pnpm --filter example-app-cucumber -r test",
|
|
61
61
|
"test:knip": "knip",
|
|
62
62
|
"test:engines": "pnpm installed-check --no-workspaces --ignore-dev",
|
|
63
63
|
"test:types": "vue-tsc --noEmit",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"dev:prepare": "nuxt prepare && unbuild --stub && pnpm -r dev:prepare"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@nuxt/kit": "^3.20.
|
|
71
|
-
"c12": "^3.3.
|
|
70
|
+
"@nuxt/kit": "^3.20.2",
|
|
71
|
+
"c12": "^3.3.3",
|
|
72
72
|
"consola": "^3.4.2",
|
|
73
73
|
"defu": "^6.1.4",
|
|
74
74
|
"destr": "^2.0.5",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"local-pkg": "^1.1.2",
|
|
81
81
|
"magic-string": "^0.30.21",
|
|
82
82
|
"node-fetch-native": "^1.6.7",
|
|
83
|
-
"node-mock-http": "^1.0.
|
|
83
|
+
"node-mock-http": "^1.0.4",
|
|
84
84
|
"ofetch": "^1.5.1",
|
|
85
85
|
"pathe": "^2.0.3",
|
|
86
86
|
"perfect-debounce": "^2.0.0",
|
|
@@ -91,17 +91,17 @@
|
|
|
91
91
|
"ufo": "^1.6.1",
|
|
92
92
|
"unplugin": "^2.3.11",
|
|
93
93
|
"vitest-environment-nuxt": "^1.0.1",
|
|
94
|
-
"vue": "^3.5.
|
|
94
|
+
"vue": "^3.5.26"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@cucumber/cucumber": "12.
|
|
97
|
+
"@cucumber/cucumber": "12.5.0",
|
|
98
98
|
"@jest/globals": "30.2.0",
|
|
99
99
|
"@nuxt/devtools-kit": "2.7.0",
|
|
100
|
-
"@nuxt/eslint-config": "1.
|
|
101
|
-
"@nuxt/schema": "4.2.
|
|
100
|
+
"@nuxt/eslint-config": "1.12.1",
|
|
101
|
+
"@nuxt/schema": "4.2.2",
|
|
102
102
|
"@playwright/test": "1.57.0",
|
|
103
103
|
"@testing-library/vue": "8.1.0",
|
|
104
|
-
"@types/bun": "1.3.
|
|
104
|
+
"@types/bun": "1.3.5",
|
|
105
105
|
"@types/estree": "1.0.8",
|
|
106
106
|
"@types/jsdom": "27.0.0",
|
|
107
107
|
"@types/node": "latest",
|
|
@@ -109,22 +109,22 @@
|
|
|
109
109
|
"@vue/test-utils": "2.4.6",
|
|
110
110
|
"changelogen": "0.6.2",
|
|
111
111
|
"compatx": "0.2.0",
|
|
112
|
-
"eslint": "9.39.
|
|
112
|
+
"eslint": "9.39.2",
|
|
113
113
|
"installed-check": "9.3.0",
|
|
114
|
-
"knip": "5.
|
|
114
|
+
"knip": "5.78.0",
|
|
115
115
|
"nitropack": "2.12.9",
|
|
116
|
-
"nuxt": "4.2.
|
|
116
|
+
"nuxt": "4.2.2",
|
|
117
117
|
"pkg-pr-new": "0.0.62",
|
|
118
118
|
"playwright-core": "1.57.0",
|
|
119
|
-
"rollup": "4.
|
|
119
|
+
"rollup": "4.54.0",
|
|
120
120
|
"semver": "7.7.3",
|
|
121
121
|
"typescript": "5.9.3",
|
|
122
122
|
"unbuild": "latest",
|
|
123
|
-
"unimport": "5.
|
|
124
|
-
"vite": "7.
|
|
123
|
+
"unimport": "5.6.0",
|
|
124
|
+
"vite": "7.3.0",
|
|
125
125
|
"vitest": "3.2.4",
|
|
126
|
-
"vue-router": "4.6.
|
|
127
|
-
"vue-tsc": "3.1
|
|
126
|
+
"vue-router": "4.6.4",
|
|
127
|
+
"vue-tsc": "3.2.1"
|
|
128
128
|
},
|
|
129
129
|
"peerDependencies": {
|
|
130
130
|
"@cucumber/cucumber": "^10.3.1 || >=11.0.0",
|
|
@@ -170,18 +170,18 @@
|
|
|
170
170
|
}
|
|
171
171
|
},
|
|
172
172
|
"resolutions": {
|
|
173
|
-
"@cucumber/cucumber": "12.
|
|
174
|
-
"@nuxt/schema": "4.2.
|
|
173
|
+
"@cucumber/cucumber": "12.5.0",
|
|
174
|
+
"@nuxt/schema": "4.2.2",
|
|
175
175
|
"@nuxt/test-utils": "workspace:*",
|
|
176
|
-
"@types/node": "24.10.
|
|
177
|
-
"rollup": "4.
|
|
178
|
-
"vite": "7.
|
|
176
|
+
"@types/node": "24.10.4",
|
|
177
|
+
"rollup": "4.54.0",
|
|
178
|
+
"vite": "7.3.0",
|
|
179
179
|
"vite-node": "5.2.0",
|
|
180
180
|
"vitest": "3.2.4",
|
|
181
|
-
"vue": "^3.5.
|
|
181
|
+
"vue": "^3.5.26"
|
|
182
182
|
},
|
|
183
183
|
"engines": {
|
|
184
184
|
"node": "^20.0.0 || ^22.0.0 || >=24.0.0"
|
|
185
185
|
},
|
|
186
|
-
"packageManager": "pnpm@10.
|
|
186
|
+
"packageManager": "pnpm@10.26.2"
|
|
187
187
|
}
|