@nuxt/test-utils 3.6.4 → 3.7.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.
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a function to render a component directly with the Nuxt server.
|
|
3
|
+
*/
|
|
4
|
+
declare function $fetchComponent(filepath: string, props?: Record<string, any>): Promise<any>;
|
|
5
|
+
declare function componentTestUrl(filepath: string, props?: Record<string, any>): string;
|
|
6
|
+
|
|
7
|
+
export { $fetchComponent, componentTestUrl };
|
package/dist/experimental.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'pathe';
|
|
2
2
|
import { stringifyQuery } from 'ufo';
|
|
3
|
-
import { $ as $fetch, u as useTestContext } from './shared/test-utils.
|
|
3
|
+
import { $ as $fetch, u as useTestContext } from './shared/test-utils.721a126c.mjs';
|
|
4
4
|
import 'execa';
|
|
5
5
|
import 'get-port-please';
|
|
6
6
|
import 'ofetch';
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as playwright_core from 'playwright-core';
|
|
2
|
+
import { Browser, BrowserContextOptions, LaunchOptions } from 'playwright-core';
|
|
3
|
+
import { NuxtConfig, Nuxt } from '@nuxt/schema';
|
|
4
|
+
import { ExecaChildProcess } from 'execa';
|
|
5
|
+
import { FetchOptions } from 'ofetch';
|
|
6
|
+
|
|
7
|
+
declare function createBrowser(): Promise<void>;
|
|
8
|
+
declare function getBrowser(): Promise<Browser>;
|
|
9
|
+
declare function createPage(path?: string, options?: BrowserContextOptions): Promise<playwright_core.Page>;
|
|
10
|
+
|
|
11
|
+
type TestRunner = 'vitest' | 'jest';
|
|
12
|
+
interface TestOptions {
|
|
13
|
+
testDir: string;
|
|
14
|
+
fixture: string;
|
|
15
|
+
configFile: string;
|
|
16
|
+
rootDir: string;
|
|
17
|
+
buildDir: string;
|
|
18
|
+
nuxtConfig: NuxtConfig;
|
|
19
|
+
build: boolean;
|
|
20
|
+
dev: boolean;
|
|
21
|
+
setupTimeout: number;
|
|
22
|
+
waitFor: number;
|
|
23
|
+
browser: boolean;
|
|
24
|
+
runner: TestRunner;
|
|
25
|
+
logLevel: number;
|
|
26
|
+
browserOptions: {
|
|
27
|
+
type: 'chromium' | 'firefox' | 'webkit';
|
|
28
|
+
launch?: LaunchOptions;
|
|
29
|
+
};
|
|
30
|
+
server: boolean;
|
|
31
|
+
port?: number;
|
|
32
|
+
}
|
|
33
|
+
interface TestContext {
|
|
34
|
+
options: TestOptions;
|
|
35
|
+
nuxt?: Nuxt;
|
|
36
|
+
browser?: Browser;
|
|
37
|
+
url?: string;
|
|
38
|
+
serverProcess?: ExecaChildProcess;
|
|
39
|
+
mockFn?: Function;
|
|
40
|
+
}
|
|
41
|
+
interface TestHooks {
|
|
42
|
+
beforeEach: () => void;
|
|
43
|
+
afterEach: () => void;
|
|
44
|
+
afterAll: () => void;
|
|
45
|
+
setup: () => void;
|
|
46
|
+
ctx: TestContext;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare function createTestContext(options: Partial<TestOptions>): TestContext;
|
|
50
|
+
declare function useTestContext(): TestContext;
|
|
51
|
+
declare function setTestContext(context: TestContext): TestContext;
|
|
52
|
+
declare function setTestContext(context?: TestContext): TestContext | undefined;
|
|
53
|
+
declare function isDev(): boolean;
|
|
54
|
+
declare function recoverContextFromEnv(): void;
|
|
55
|
+
declare function exposeContextToEnv(): void;
|
|
56
|
+
|
|
57
|
+
declare function mockFn(): Function | undefined;
|
|
58
|
+
declare function mockLogger(): Record<string, Function>;
|
|
59
|
+
|
|
60
|
+
declare function loadFixture(): Promise<void>;
|
|
61
|
+
declare function buildFixture(): Promise<void>;
|
|
62
|
+
|
|
63
|
+
declare function startServer(): Promise<void>;
|
|
64
|
+
declare function stopServer(): Promise<void>;
|
|
65
|
+
declare function fetch(path: string, options?: any): Promise<Response>;
|
|
66
|
+
declare function $fetch(path: string, options?: FetchOptions): Promise<any>;
|
|
67
|
+
declare function url(path: string): string;
|
|
68
|
+
|
|
69
|
+
declare function setupJest(hooks: TestHooks): Promise<void>;
|
|
70
|
+
|
|
71
|
+
declare function setupVitest(hooks: TestHooks): Promise<void>;
|
|
72
|
+
|
|
73
|
+
declare const setupMaps: {
|
|
74
|
+
jest: typeof setupJest;
|
|
75
|
+
vitest: typeof setupVitest;
|
|
76
|
+
};
|
|
77
|
+
declare function createTest(options: Partial<TestOptions>): TestHooks;
|
|
78
|
+
declare function setup(options?: Partial<TestOptions>): Promise<void>;
|
|
79
|
+
|
|
80
|
+
interface RunTestOptions {
|
|
81
|
+
rootDir: string;
|
|
82
|
+
dev?: boolean;
|
|
83
|
+
watch?: boolean;
|
|
84
|
+
runner?: 'vitest';
|
|
85
|
+
globalSetup?: boolean;
|
|
86
|
+
}
|
|
87
|
+
declare function runTests(opts: RunTestOptions): Promise<void>;
|
|
88
|
+
|
|
89
|
+
export { $fetch, type RunTestOptions, type TestContext, type TestHooks, type TestOptions, type TestRunner, buildFixture, createBrowser, createPage, createTest, createTestContext, exposeContextToEnv, fetch, getBrowser, isDev, loadFixture, mockFn, mockLogger, recoverContextFromEnv, runTests, setTestContext, setup, setupMaps, startServer, stopServer, url, useTestContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -86,4 +86,4 @@ interface RunTestOptions {
|
|
|
86
86
|
}
|
|
87
87
|
declare function runTests(opts: RunTestOptions): Promise<void>;
|
|
88
88
|
|
|
89
|
-
export { $fetch, RunTestOptions, TestContext, TestHooks, TestOptions, TestRunner, buildFixture, createBrowser, createPage, createTest, createTestContext, exposeContextToEnv, fetch, getBrowser, isDev, loadFixture, mockFn, mockLogger, recoverContextFromEnv, runTests, setTestContext, setup, setupMaps, startServer, stopServer, url, useTestContext };
|
|
89
|
+
export { $fetch, type RunTestOptions, type TestContext, type TestHooks, type TestOptions, type TestRunner, buildFixture, createBrowser, createPage, createTest, createTestContext, exposeContextToEnv, fetch, getBrowser, isDev, loadFixture, mockFn, mockLogger, recoverContextFromEnv, runTests, setTestContext, setup, setupMaps, startServer, stopServer, url, useTestContext };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as useTestContext, a as url, c as createTestContext, s as setTestContext, b as stopServer, d as startServer } from './shared/test-utils.
|
|
2
|
-
export { $ as $fetch, e as exposeContextToEnv, f as fetch, i as isDev, r as recoverContextFromEnv } from './shared/test-utils.
|
|
1
|
+
import { u as useTestContext, a as url, c as createTestContext, s as setTestContext, b as stopServer, d as startServer } from './shared/test-utils.721a126c.mjs';
|
|
2
|
+
export { $ as $fetch, e as exposeContextToEnv, f as fetch, i as isDev, r as recoverContextFromEnv } from './shared/test-utils.721a126c.mjs';
|
|
3
3
|
import { consola } from 'consola';
|
|
4
4
|
import { promises, existsSync } from 'node:fs';
|
|
5
5
|
import { resolve } from 'node:path';
|
|
@@ -61,11 +61,12 @@ async function startServer() {
|
|
|
61
61
|
ctx.url = "http://127.0.0.1:" + port;
|
|
62
62
|
if (ctx.options.dev) {
|
|
63
63
|
const nuxiCLI = await kit.resolvePath("nuxi/cli");
|
|
64
|
-
ctx.serverProcess = execa(nuxiCLI, ["
|
|
64
|
+
ctx.serverProcess = execa(nuxiCLI, ["_dev"], {
|
|
65
65
|
cwd: ctx.nuxt.options.rootDir,
|
|
66
66
|
stdio: "inherit",
|
|
67
67
|
env: {
|
|
68
68
|
...process.env,
|
|
69
|
+
_PORT: String(port),
|
|
69
70
|
PORT: String(port),
|
|
70
71
|
NITRO_PORT: String(port),
|
|
71
72
|
NODE_ENV: "development"
|
|
@@ -73,7 +74,7 @@ async function startServer() {
|
|
|
73
74
|
});
|
|
74
75
|
await waitForPort(port, { retries: 32 });
|
|
75
76
|
let lastError;
|
|
76
|
-
for (let i = 0; i <
|
|
77
|
+
for (let i = 0; i < 150; i++) {
|
|
77
78
|
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
78
79
|
try {
|
|
79
80
|
const res = await $fetch(ctx.nuxt.options.app.baseURL);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/test-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"repository": "nuxt/nuxt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,17 +21,17 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"consola": "^3.2.3",
|
|
23
23
|
"defu": "^6.1.2",
|
|
24
|
-
"execa": "^7.
|
|
24
|
+
"execa": "^7.2.0",
|
|
25
25
|
"get-port-please": "^3.0.1",
|
|
26
|
-
"ofetch": "^1.
|
|
26
|
+
"ofetch": "^1.3.3",
|
|
27
27
|
"pathe": "^1.1.1",
|
|
28
|
-
"ufo": "^1.
|
|
29
|
-
"@nuxt/kit": "3.
|
|
30
|
-
"@nuxt/schema": "3.
|
|
28
|
+
"ufo": "^1.3.0",
|
|
29
|
+
"@nuxt/kit": "3.7.0",
|
|
30
|
+
"@nuxt/schema": "3.7.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@jest/globals": "29.6.
|
|
34
|
-
"playwright-core": "1.
|
|
33
|
+
"@jest/globals": "29.6.4",
|
|
34
|
+
"playwright-core": "1.37.1",
|
|
35
35
|
"unbuild": "latest",
|
|
36
36
|
"vitest": "0.33.0"
|
|
37
37
|
},
|