@nuxt/test-utils-nightly 3.21.1-20251231-210330-86b4998 → 3.22.0-20251231-210716-73de59a
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 +2 -3
- package/dist/config.mjs +0 -3
- package/dist/e2e.d.mts +2 -2
- package/dist/module.mjs +246 -129
- package/dist/playwright.d.mts +1 -1
- package/dist/shared/test-utils-nightly.DDUpsMYL.mjs +32 -0
- package/dist/shared/{test-utils-nightly.20kU0tZa.d.mts → test-utils-nightly.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 +1 -1
package/dist/config.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import * as vite from 'vite';
|
|
2
|
-
import { UserConfig } from 'vite';
|
|
3
1
|
import { NuxtConfig, Nuxt } from '@nuxt/schema';
|
|
4
2
|
import { InlineConfig } from 'vitest/node';
|
|
5
3
|
import { TestProjectInlineConfiguration } from 'vitest/config';
|
|
6
4
|
import { DotenvOptions } from 'c12';
|
|
5
|
+
import { UserConfig, UserConfigFnPromise } from 'vite';
|
|
7
6
|
|
|
8
7
|
interface GetVitestConfigOptions {
|
|
9
8
|
nuxt: Nuxt;
|
|
@@ -19,7 +18,7 @@ declare function getVitestConfigFromNuxt(options?: GetVitestConfigOptions, loadN
|
|
|
19
18
|
declare function defineVitestProject(config: TestProjectInlineConfiguration): Promise<TestProjectInlineConfiguration>;
|
|
20
19
|
declare function defineVitestConfig(config?: UserConfig & {
|
|
21
20
|
test?: InlineConfig;
|
|
22
|
-
}):
|
|
21
|
+
}): UserConfigFnPromise;
|
|
23
22
|
interface NuxtEnvironmentOptions {
|
|
24
23
|
rootDir?: string;
|
|
25
24
|
/**
|
package/dist/config.mjs
CHANGED
|
@@ -91,7 +91,6 @@ async function getVitestConfigFromNuxt(options, loadNuxtOptions = {}) {
|
|
|
91
91
|
noDiscovery: true
|
|
92
92
|
},
|
|
93
93
|
test: {
|
|
94
|
-
dir: process.cwd(),
|
|
95
94
|
environmentOptions: {
|
|
96
95
|
nuxtRuntimeConfig: applyEnv(structuredClone(options.nuxt.options.runtimeConfig), {
|
|
97
96
|
prefix: "NUXT_",
|
|
@@ -188,14 +187,12 @@ async function getVitestConfigFromNuxt(options, loadNuxtOptions = {}) {
|
|
|
188
187
|
return resolvedConfig;
|
|
189
188
|
}
|
|
190
189
|
async function defineVitestProject(config) {
|
|
191
|
-
if (process.env.__NUXT_VITEST_RESOLVED__) return config;
|
|
192
190
|
const resolvedConfig = await resolveConfig(config);
|
|
193
191
|
resolvedConfig.test.environment = "nuxt";
|
|
194
192
|
return resolvedConfig;
|
|
195
193
|
}
|
|
196
194
|
function defineVitestConfig(config = {}) {
|
|
197
195
|
return defineConfig(async () => {
|
|
198
|
-
if (process.env.__NUXT_VITEST_RESOLVED__) return config;
|
|
199
196
|
const resolvedConfig = await resolveConfig(config);
|
|
200
197
|
if (resolvedConfig.test.browser?.enabled) {
|
|
201
198
|
return resolvedConfig;
|
package/dist/e2e.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TestOptions,
|
|
2
|
-
export { $ as $fetch, G as GotoOptions, N as NuxtPage, S as StartServerOptions, h as TestRunner, c as createBrowser, d as createPage, f as fetch, g as getBrowser, s as startServer, e as stopServer, u as url, w as waitForHydration } from './shared/test-utils-nightly.
|
|
1
|
+
import { T as TestOptions, b as TestContext, a as TestHooks } from './shared/test-utils-nightly.ZByFDqps.mjs';
|
|
2
|
+
export { $ as $fetch, G as GotoOptions, N as NuxtPage, S as StartServerOptions, h as TestRunner, c as createBrowser, d as createPage, f as fetch, g as getBrowser, s as startServer, e as stopServer, u as url, w as waitForHydration } from './shared/test-utils-nightly.ZByFDqps.mjs';
|
|
3
3
|
import { LogType } from 'consola';
|
|
4
4
|
import 'playwright-core';
|
|
5
5
|
import '@nuxt/schema';
|
package/dist/module.mjs
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { h } from 'vue';
|
|
5
|
-
import { debounce } from 'perfect-debounce';
|
|
6
|
-
import { isCI } from 'std-env';
|
|
7
|
-
import { defu } from 'defu';
|
|
8
|
-
import { extname, join, dirname, relative } from 'pathe';
|
|
9
|
-
import { getVitestConfigFromNuxt } from './config.mjs';
|
|
1
|
+
import { resolveIgnorePatterns, useNuxt, addDevServerHandler, defineNuxtModule, createResolver, resolvePath, logger } from '@nuxt/kit';
|
|
2
|
+
import { extname, join, dirname, resolve, relative } from 'pathe';
|
|
3
|
+
import { provider, isCI } from 'std-env';
|
|
10
4
|
import { walk } from 'estree-walker';
|
|
11
5
|
import MagicString from 'magic-string';
|
|
12
6
|
import { createUnplugin } from 'unplugin';
|
|
13
7
|
import { l as loadKit } from './shared/test-utils-nightly.G1ew4kEe.mjs';
|
|
14
8
|
import { readFileSync } from 'node:fs';
|
|
15
|
-
import '
|
|
16
|
-
import '
|
|
17
|
-
import '
|
|
9
|
+
import { h } from 'vue';
|
|
10
|
+
import { defineEventHandler } from 'h3';
|
|
11
|
+
import { debounce } from 'perfect-debounce';
|
|
12
|
+
import { fork } from 'node:child_process';
|
|
13
|
+
import { c as createVitestTestSummary, l as listenCliMessages, s as sendMessageToCli } from './shared/test-utils-nightly.DDUpsMYL.mjs';
|
|
14
|
+
import { distDir } from '#dirs';
|
|
18
15
|
import 'destr';
|
|
19
16
|
import 'scule';
|
|
17
|
+
import 'node:url';
|
|
20
18
|
import 'exsolve';
|
|
21
19
|
|
|
22
20
|
const PLUGIN_NAME$1 = "nuxt:vitest:mock-transform";
|
|
@@ -325,7 +323,204 @@ const NuxtRootStubPlugin = (options) => {
|
|
|
325
323
|
};
|
|
326
324
|
};
|
|
327
325
|
|
|
328
|
-
|
|
326
|
+
async function setupDevTools(vitestWrapper, nuxt = useNuxt()) {
|
|
327
|
+
const iframeSrc = "/__test_utils_vitest__/";
|
|
328
|
+
const updateTabs = debounce(() => {
|
|
329
|
+
nuxt.callHook("devtools:customTabs:refresh");
|
|
330
|
+
}, 100);
|
|
331
|
+
nuxt.hook("devtools:customTabs", (tabs) => {
|
|
332
|
+
const tab = createVitestCustomTab(vitestWrapper, { iframeSrc });
|
|
333
|
+
const index = tabs.findIndex(({ name }) => tab.name === name);
|
|
334
|
+
if (index === -1) {
|
|
335
|
+
tabs.push(tab);
|
|
336
|
+
} else {
|
|
337
|
+
tabs.splice(index, 1, tab);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
addDevServerHandler({
|
|
341
|
+
route: iframeSrc,
|
|
342
|
+
handler: defineEventHandler(
|
|
343
|
+
() => iframeContentHtml(vitestWrapper.uiUrl)
|
|
344
|
+
)
|
|
345
|
+
});
|
|
346
|
+
vitestWrapper.ons({
|
|
347
|
+
started() {
|
|
348
|
+
updateTabs();
|
|
349
|
+
},
|
|
350
|
+
updated() {
|
|
351
|
+
updateTabs();
|
|
352
|
+
},
|
|
353
|
+
finished() {
|
|
354
|
+
updateTabs();
|
|
355
|
+
},
|
|
356
|
+
exited() {
|
|
357
|
+
updateTabs();
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function createVitestCustomTab(vitest, { iframeSrc }) {
|
|
362
|
+
const launchView = {
|
|
363
|
+
type: "launch",
|
|
364
|
+
description: "Start tests along with Nuxt",
|
|
365
|
+
actions: [
|
|
366
|
+
{
|
|
367
|
+
get label() {
|
|
368
|
+
switch (vitest.status) {
|
|
369
|
+
case "starting":
|
|
370
|
+
return "Starting...";
|
|
371
|
+
case "running":
|
|
372
|
+
return "Running Vitest";
|
|
373
|
+
case "stopped":
|
|
374
|
+
return "Start Vitest";
|
|
375
|
+
case "finished":
|
|
376
|
+
return "Start Vitest";
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
get pending() {
|
|
380
|
+
return vitest.status === "starting" || vitest.status === "running";
|
|
381
|
+
},
|
|
382
|
+
handle: () => {
|
|
383
|
+
vitest.start();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
]
|
|
387
|
+
};
|
|
388
|
+
const uiView = {
|
|
389
|
+
type: "iframe",
|
|
390
|
+
persistent: false,
|
|
391
|
+
src: iframeSrc
|
|
392
|
+
};
|
|
393
|
+
const tab = {
|
|
394
|
+
title: "Vitest",
|
|
395
|
+
name: "vitest",
|
|
396
|
+
icon: "logos-vitest",
|
|
397
|
+
get view() {
|
|
398
|
+
if (vitest.status === "stopped" || vitest.status === "starting" || !vitest.uiUrl) {
|
|
399
|
+
return launchView;
|
|
400
|
+
} else {
|
|
401
|
+
return uiView;
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
extraTabVNode: vitest.testSummary.totalCount ? h("div", { style: { color: vitest.testSummary.failedCount ? "orange" : "green" } }, [
|
|
405
|
+
h("span", {}, vitest.testSummary.passedCount),
|
|
406
|
+
h("span", { style: { opacity: "0.5", fontSize: "0.9em" } }, "/"),
|
|
407
|
+
h(
|
|
408
|
+
"span",
|
|
409
|
+
{ style: { opacity: "0.8", fontSize: "0.9em" } },
|
|
410
|
+
vitest.testSummary.totalCount
|
|
411
|
+
)
|
|
412
|
+
]) : void 0
|
|
413
|
+
};
|
|
414
|
+
return tab;
|
|
415
|
+
}
|
|
416
|
+
function iframeContentHtml(uiUrl) {
|
|
417
|
+
return [
|
|
418
|
+
"<html><head><script>",
|
|
419
|
+
`(${function redirect(uiUrl2, provider2) {
|
|
420
|
+
if (typeof window === "undefined") return;
|
|
421
|
+
if (!uiUrl2) return;
|
|
422
|
+
if (provider2 === "stackblitz") {
|
|
423
|
+
const url = new URL(window.location.href);
|
|
424
|
+
const newUrl = new URL(uiUrl2);
|
|
425
|
+
newUrl.host = url.host.replace(/--\d+--/, `--${newUrl.port}--`);
|
|
426
|
+
newUrl.protocol = url.protocol;
|
|
427
|
+
newUrl.port = url.port;
|
|
428
|
+
uiUrl2 = newUrl.toString();
|
|
429
|
+
}
|
|
430
|
+
window.location.replace(uiUrl2);
|
|
431
|
+
}})(${JSON.stringify(uiUrl)}, ${JSON.stringify(provider)})`,
|
|
432
|
+
"<\/script></head></html>"
|
|
433
|
+
].join("\n");
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function vitestWrapper(options) {
|
|
437
|
+
const { cwd, ...startOptions } = options;
|
|
438
|
+
let _status = "stopped";
|
|
439
|
+
let _uiUrl;
|
|
440
|
+
let _process;
|
|
441
|
+
let _testSummary = createVitestTestSummary();
|
|
442
|
+
const _handlers = {
|
|
443
|
+
started: [({ uiUrl }) => {
|
|
444
|
+
_uiUrl = uiUrl;
|
|
445
|
+
_status = "running";
|
|
446
|
+
_testSummary = createVitestTestSummary();
|
|
447
|
+
}],
|
|
448
|
+
updated: [(summary) => {
|
|
449
|
+
_testSummary = summary;
|
|
450
|
+
}],
|
|
451
|
+
finished: [(summary) => {
|
|
452
|
+
_status = "finished";
|
|
453
|
+
_testSummary = summary;
|
|
454
|
+
}],
|
|
455
|
+
exited: [clear]
|
|
456
|
+
};
|
|
457
|
+
function clear() {
|
|
458
|
+
_status = "stopped";
|
|
459
|
+
_uiUrl = void 0;
|
|
460
|
+
_process = void 0;
|
|
461
|
+
_testSummary = createVitestTestSummary();
|
|
462
|
+
}
|
|
463
|
+
function on(name, handler) {
|
|
464
|
+
_handlers[name] ??= [];
|
|
465
|
+
_handlers[name]?.push(handler);
|
|
466
|
+
}
|
|
467
|
+
function ons(handlers) {
|
|
468
|
+
for (const [name, handler] of Object.entries(handlers)) {
|
|
469
|
+
if (typeof handler === "function") {
|
|
470
|
+
on(name, handler);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
async function stop() {
|
|
475
|
+
const vitest = _process;
|
|
476
|
+
if (!vitest || vitest.exitCode !== null) return;
|
|
477
|
+
return new Promise((resolve2) => {
|
|
478
|
+
vitest.once("exit", () => resolve2());
|
|
479
|
+
sendMessageToCli(vitest, "stop", { force: true });
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
async function start() {
|
|
483
|
+
if (_process) return false;
|
|
484
|
+
const vitest = fork(resolve(distDir, "./vitest-wrapper/cli.mjs"), {
|
|
485
|
+
cwd,
|
|
486
|
+
env: {
|
|
487
|
+
...process.env,
|
|
488
|
+
NODE_ENV: "test",
|
|
489
|
+
MODE: "test"
|
|
490
|
+
},
|
|
491
|
+
stdio: startOptions.logToConsole ? void 0 : ["ignore", "ignore", "inherit", "ipc"]
|
|
492
|
+
});
|
|
493
|
+
_status = "starting";
|
|
494
|
+
_process = vitest;
|
|
495
|
+
vitest.once("exit", () => {
|
|
496
|
+
_handlers.exited.forEach((fn) => fn({ exitCode: vitest.exitCode ?? 0 }));
|
|
497
|
+
});
|
|
498
|
+
listenCliMessages(vitest, ({ type, payload }) => {
|
|
499
|
+
_handlers[type].forEach((fn) => fn(payload));
|
|
500
|
+
});
|
|
501
|
+
sendMessageToCli(vitest, "start", startOptions);
|
|
502
|
+
return true;
|
|
503
|
+
}
|
|
504
|
+
return {
|
|
505
|
+
on,
|
|
506
|
+
ons,
|
|
507
|
+
stop,
|
|
508
|
+
start,
|
|
509
|
+
get uiUrl() {
|
|
510
|
+
return _uiUrl;
|
|
511
|
+
},
|
|
512
|
+
get options() {
|
|
513
|
+
return options;
|
|
514
|
+
},
|
|
515
|
+
get status() {
|
|
516
|
+
return _status;
|
|
517
|
+
},
|
|
518
|
+
get testSummary() {
|
|
519
|
+
return { ..._testSummary };
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
|
|
329
524
|
const module$1 = defineNuxtModule({
|
|
330
525
|
meta: {
|
|
331
526
|
name: "@nuxt/test-utils",
|
|
@@ -351,133 +546,55 @@ const module$1 = defineNuxtModule({
|
|
|
351
546
|
nuxt.options.vite.define ||= {};
|
|
352
547
|
nuxt.options.vite.define["import.meta.vitest"] = "undefined";
|
|
353
548
|
}
|
|
354
|
-
nuxt.hook("prepare:types", (
|
|
355
|
-
|
|
356
|
-
if (
|
|
357
|
-
|
|
358
|
-
|
|
549
|
+
nuxt.hook("prepare:types", (ctx) => {
|
|
550
|
+
ctx.references.push({ types: "vitest/import-meta" });
|
|
551
|
+
if (ctx.nodeTsConfig) {
|
|
552
|
+
ctx.nodeTsConfig.include ||= [];
|
|
553
|
+
ctx.nodeTsConfig.include.push(relative(nuxt.options.buildDir, join(nuxt.options.rootDir, "vitest.config.*")));
|
|
359
554
|
if (nuxt.options.workspaceDir !== nuxt.options.rootDir) {
|
|
360
|
-
|
|
555
|
+
ctx.nodeTsConfig.include.push(relative(nuxt.options.buildDir, join(nuxt.options.workspaceDir, "vitest.config.*")));
|
|
361
556
|
}
|
|
362
557
|
}
|
|
363
558
|
});
|
|
364
559
|
if (!nuxt.options.dev) return;
|
|
365
560
|
if (process.env.TEST || process.env.VITE_TEST) return;
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
let loaded = false;
|
|
374
|
-
let promise;
|
|
375
|
-
let ctx = void 0;
|
|
376
|
-
let testFiles = null;
|
|
377
|
-
const updateTabs = debounce(() => {
|
|
378
|
-
nuxt.callHook("devtools:customTabs:refresh");
|
|
379
|
-
}, 100);
|
|
380
|
-
let URL;
|
|
381
|
-
async function start() {
|
|
382
|
-
const { mergeConfig } = await importModule("vite", { paths: nuxt.options.modulesDir });
|
|
383
|
-
const rawViteConfig = mergeConfig({}, await rawViteConfigPromise);
|
|
384
|
-
const viteConfig = await getVitestConfigFromNuxt({ nuxt, viteConfig: defu({ test: options.vitestConfig }, rawViteConfig) });
|
|
385
|
-
viteConfig.plugins = (viteConfig.plugins || []).filter((p) => {
|
|
386
|
-
return !p || !("name" in p) || !vitePluginBlocklist.includes(p.name);
|
|
387
|
-
});
|
|
388
|
-
viteConfig.test.environmentMatchGlobs ||= [];
|
|
389
|
-
viteConfig.test.environmentMatchGlobs.push(
|
|
390
|
-
["**/*.nuxt.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}", "nuxt"],
|
|
391
|
-
["{test,tests}/nuxt/**.*", "nuxt"]
|
|
392
|
-
);
|
|
393
|
-
process.env.__NUXT_VITEST_RESOLVED__ = "true";
|
|
394
|
-
const { startVitest } = await import(pathToFileURL(await resolvePath("vitest/node")).href);
|
|
395
|
-
const customReporter = {
|
|
396
|
-
onInit(_ctx) {
|
|
397
|
-
ctx = _ctx;
|
|
398
|
-
},
|
|
399
|
-
onTaskUpdate() {
|
|
400
|
-
testFiles = ctx.state.getFiles();
|
|
401
|
-
updateTabs();
|
|
402
|
-
},
|
|
403
|
-
onFinished() {
|
|
404
|
-
testFiles = ctx.state.getFiles();
|
|
405
|
-
updateTabs();
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
const watchMode = !process.env.NUXT_VITEST_DEV_TEST && !isCI;
|
|
409
|
-
const PORT = await getPort({ port: 15555 });
|
|
410
|
-
const PROTOCOL = nuxt.options.devServer.https ? "https" : "http";
|
|
411
|
-
URL = `${PROTOCOL}://localhost:${PORT}/__vitest__/`;
|
|
412
|
-
const overrides = watchMode ? {
|
|
413
|
-
passWithNoTests: true,
|
|
414
|
-
reporters: options.logToConsole ? [
|
|
415
|
-
...toArray(options.vitestConfig?.reporters ?? ["default"]),
|
|
416
|
-
customReporter
|
|
417
|
-
] : [customReporter],
|
|
418
|
-
// do not report to console
|
|
419
|
-
watch: true,
|
|
420
|
-
ui: true,
|
|
421
|
-
open: false,
|
|
422
|
-
api: {
|
|
423
|
-
port: PORT
|
|
424
|
-
}
|
|
425
|
-
} : { watch: false };
|
|
426
|
-
const promise2 = startVitest("test", [], defu(overrides, viteConfig.test), viteConfig);
|
|
427
|
-
promise2.catch(() => process.exit(1));
|
|
428
|
-
if (watchMode) {
|
|
429
|
-
logger.info(`Vitest UI starting on ${URL}`);
|
|
430
|
-
nuxt.hook("close", () => promise2.then((v) => v?.close()));
|
|
431
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
432
|
-
} else {
|
|
433
|
-
promise2.then((v) => nuxt.close().then(() => v?.close()).then(() => process.exit()));
|
|
434
|
-
}
|
|
435
|
-
loaded = true;
|
|
561
|
+
const vitestWrapper2 = createVitestWrapper(options, nuxt);
|
|
562
|
+
const isDevToolsEnabled = typeof nuxt.options.devtools === "boolean" ? nuxt.options.devtools : nuxt.options.devtools.enabled;
|
|
563
|
+
if (isDevToolsEnabled) {
|
|
564
|
+
await setupDevTools(vitestWrapper2, nuxt);
|
|
436
565
|
}
|
|
437
|
-
nuxt.hook("devtools:customTabs", (tabs) => {
|
|
438
|
-
const failedCount = testFiles?.filter((f) => f.result?.state === "fail").length ?? 0;
|
|
439
|
-
const passedCount = testFiles?.filter((f) => f.result?.state === "pass").length ?? 0;
|
|
440
|
-
const totalCount = testFiles?.length ?? 0;
|
|
441
|
-
tabs.push({
|
|
442
|
-
title: "Vitest",
|
|
443
|
-
name: "vitest",
|
|
444
|
-
icon: "logos-vitest",
|
|
445
|
-
view: loaded ? {
|
|
446
|
-
type: "iframe",
|
|
447
|
-
src: URL
|
|
448
|
-
} : {
|
|
449
|
-
type: "launch",
|
|
450
|
-
description: "Start tests along with Nuxt",
|
|
451
|
-
actions: [
|
|
452
|
-
{
|
|
453
|
-
label: promise ? "Starting..." : "Start Vitest",
|
|
454
|
-
pending: !!promise,
|
|
455
|
-
handle: () => {
|
|
456
|
-
promise = promise || start();
|
|
457
|
-
return promise;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
]
|
|
461
|
-
},
|
|
462
|
-
extraTabVNode: totalCount ? h("div", { style: { color: failedCount ? "orange" : "green" } }, [
|
|
463
|
-
h("span", {}, passedCount),
|
|
464
|
-
h("span", { style: { opacity: "0.5", fontSize: "0.9em" } }, "/"),
|
|
465
|
-
h(
|
|
466
|
-
"span",
|
|
467
|
-
{ style: { opacity: "0.8", fontSize: "0.9em" } },
|
|
468
|
-
totalCount
|
|
469
|
-
)
|
|
470
|
-
]) : void 0
|
|
471
|
-
});
|
|
472
|
-
});
|
|
473
566
|
if (options.startOnBoot) {
|
|
474
|
-
|
|
475
|
-
promise.then(updateTabs);
|
|
567
|
+
vitestWrapper2.start();
|
|
476
568
|
}
|
|
477
569
|
}
|
|
478
570
|
});
|
|
479
|
-
function
|
|
480
|
-
|
|
571
|
+
function createVitestWrapper(options, nuxt = useNuxt()) {
|
|
572
|
+
const watchMode = !isCI;
|
|
573
|
+
const wrapper = vitestWrapper({
|
|
574
|
+
cwd: nuxt.options.rootDir,
|
|
575
|
+
apiPorts: [15555],
|
|
576
|
+
logToConsole: options.logToConsole ?? false,
|
|
577
|
+
watchMode
|
|
578
|
+
});
|
|
579
|
+
wrapper.ons({
|
|
580
|
+
started({ uiUrl }) {
|
|
581
|
+
if (watchMode) {
|
|
582
|
+
logger.info(`Vitest UI starting on ${uiUrl}`);
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
exited({ exitCode }) {
|
|
586
|
+
if (watchMode) {
|
|
587
|
+
logger.info(`Vitest exited with code ${exitCode}`);
|
|
588
|
+
} else {
|
|
589
|
+
nuxt.close().finally(() => process.exit(exitCode));
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
nuxt.hooks.addHooks({
|
|
594
|
+
close: () => wrapper.stop(),
|
|
595
|
+
restart: () => wrapper.stop()
|
|
596
|
+
});
|
|
597
|
+
return wrapper;
|
|
481
598
|
}
|
|
482
599
|
|
|
483
600
|
export { module$1 as default };
|
package/dist/playwright.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _playwright_test from '@playwright/test';
|
|
2
2
|
export { expect } from '@playwright/test';
|
|
3
3
|
import { Response } from 'playwright-core';
|
|
4
|
-
import { T as TestOptions$1, G as GotoOptions,
|
|
4
|
+
import { T as TestOptions$1, G as GotoOptions, a as TestHooks } from './shared/test-utils-nightly.ZByFDqps.mjs';
|
|
5
5
|
import '@nuxt/schema';
|
|
6
6
|
import 'tinyexec';
|
|
7
7
|
|
|
@@ -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-nightly.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();
|