@nuxt/test-utils 3.6.5 → 3.7.1

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 CHANGED
@@ -1,113 +1,52 @@
1
+ [![Nuxt banner](./.github/assets/banner.svg)](https://nuxt.com)
1
2
 
2
- [![Nuxt banner](./.github/assets/banner.png)](https://nuxt.com)
3
+ # Nuxt
3
4
 
4
- # 👋 Welcome to Nuxt
5
+ <p>
6
+ <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
7
+ <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
8
+ <a href="./LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
9
+ <a href="https://nuxt.com"><img src="https://img.shields.io/badge/Nuxt%20Docs-18181B?logo=nuxt.js" alt="Website"></a>
10
+ <a href="https://chat.nuxt.dev"><img src="https://img.shields.io/badge/Nuxt%20Discord-18181B?logo=discord" alt="Discord"></a>
11
+ </p>
5
12
 
13
+ Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.
6
14
 
7
- Nuxt's goal is to make web development intuitive and performant, with a great developer experience.<br>Learn more in the ['What is Nuxt?'](https://nuxt.com/docs/getting-started/introduction) section of our documentation.
15
+ It provides a number of features that make it easy to build fast, SEO-friendly, and scalable web applications, including:
16
+ - Server-side rendering, Static Site Generation or Hybrid Rendering
17
+ - Automatic routing with code-splitting
18
+ - State management
19
+ - SEO Optimization
20
+ - Extandable with [100+ modules](https://nuxt.com/modules)
21
+ - Deployment to a variety of hosting platforms
22
+ - ...[and much more](https://nuxt.com) 🚀
8
23
 
24
+ ## Getting Started
9
25
 
10
- <p>
11
- <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/v/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version"></a>
12
- <a href="https://www.npmjs.com/package/nuxt"><img src="https://img.shields.io/npm/dm/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads"></a>
13
- <a href="./LICENSE"><img src="https://img.shields.io/github/license/nuxt/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License"></a>
14
- <a href="https://nuxt.com"><img src="https://img.shields.io/badge/Open%20Documentation-18181B?logo=nuxt.js" alt="Website"></a>
15
- <a href="https://volta.net/nuxt/nuxt?utm_source=nuxt_readme"><img src="https://user-images.githubusercontent.com/904724/209143798-32345f6c-3cf8-4e06-9659-f4ace4a6acde.svg" alt="Volta board"></a>
16
- </p>
17
-
18
- <table>
19
- <thead>
20
- <tr>
21
- <th width="2000" colspan="2">
22
- </th>
23
- </tr>
24
- </thead>
25
- <tbody>
26
- <tr>
27
- <td width="80" align="center" valign="top">
28
- <br>
29
- <a href="https://nuxt.com/docs"><img src="./.github/assets/documentation.png"></a>
30
- </td>
31
- <td valign="top">
32
- <h3>Documentation</h3>
33
- <p>
34
- We highly recommend you take a look at <a href="https://nuxt.com">the Nuxt documentation</a> to level up.
35
- </p>
36
- </td>
37
- </tr>
38
- <tr>
39
- <td width="80" align="center" valign="top">
40
- <br>
41
- <a href="https://nuxt.com/modules"><img src="./.github/assets/modules.png"></a>
42
- </td>
43
- <td valign="top">
44
- <h3>Modules</h3>
45
- <p>
46
- Discover our <a href="https://nuxt.com/modules">list of modules</a> to supercharge your Nuxt project. Created by the Nuxt team and community.
47
- </p>
48
- </td>
49
- </tr>
50
- <tr>
51
- <td width="80" align="center" valign="top">
52
- <br>
53
- <a href="https://nuxt.com/docs/examples/hello-world"><img src="./.github/assets/examples.png"></a>
54
- </td>
55
- <td>
56
- <h3>Examples</h3>
57
- <p>
58
- Explore different ways of using Nuxt features and get inspired with <a href="https://nuxt.com/docs/examples/hello-world">our list of examples</a>.
59
- </p>
60
- </td>
61
- </tr>
62
- </tbody>
63
- </table>
64
-
65
- <table>
66
- <thead>
67
- <tr>
68
- <th width="2000" colspan="2">
69
- </th>
70
- </tr>
71
- </thead>
72
- <tbody>
73
- <tr>
74
- <td width="80" align="center" valign="top">
75
- <br>
76
- <a href="https://nuxt.com/docs/community/reporting-bugs"><img src="./.github/assets/reporting-bugs.png"></a>
77
- </td>
78
- <td valign="top">
79
- <h3>Reporting bugs</h3>
80
- <p>
81
- Check out the <a href="https://nuxt.com/docs/community/reporting-bugs">Reporting Bugs</a> page.</p>
82
- </p>
83
- </td>
84
- </tr>
85
- <tr>
86
- <td width="80" align="center" valign="top">
87
- <br>
88
- <a href="https://nuxt.com/docs/community/contribution"><img src="./.github/assets/suggestions.png"></a>
89
- </td>
90
- <td valign="top">
91
- <h3>Suggestions</h3>
92
- <p>
93
- Check out the <a href="https://nuxt.com/docs/community/contribution">Contribution</a> page.
94
- </p>
95
- </td>
96
- </tr>
97
- <tr>
98
- <td width="80" align="center" valign="top">
99
- <br>
100
- <a href="https://nuxt.com/docs/community/getting-help"><img src="./.github/assets/questions.png"></a>
101
- </td>
102
- <td valign="top">
103
- <h3>Questions</h3>
104
- <p>
105
- Check out the <a href="https://nuxt.com/docs/community/getting-help">Getting Help</a> page.
106
- </p>
107
- </td>
108
- </tr>
109
- </tbody>
110
- </table>
26
+ Use the following command to create a new starter project. This will create a starter project with all the necessary files and dependencies:
27
+
28
+ ```bash
29
+ npx nuxi@latest nuxi init <my-project>
30
+ ```
31
+
32
+ Discover also [nuxt.new](https://nuxt.new): Open a Nuxt starter on CodeSandbox, StackBlitz or locally to get up and running in a few seconds.
33
+
34
+ ## Documentation
35
+
36
+ We highly recommend you take a look at the [Nuxt documentation](https://nuxt.com/docs) to level up. It’s a great resource for learning more about the framework. It covers everything from getting started to advanced topics.
37
+
38
+ ## Modules
39
+
40
+ Discover our [list of modules](https://nuxt.com/modules) to supercharge your Nuxt project, created by the Nuxt team and community.
41
+
42
+ ## Contribute
43
+
44
+ We invite you to contribute and help improve Nuxt 💚
45
+
46
+ Here are a few ways you can get involved:
47
+ - **Reporting Bugs:** If you come across any bugs or issues, please check out the [reporting bugs guide](https://nuxt.com/docs/community/reporting-bugs) to learn how to submit a bug report.
48
+ - **Suggestions:** Have ideas to enhance Nuxt? We'd love to hear them! Check out the [contribution guide](https://nuxt.com/docs/community/contribution#creating-an-issue) to share your suggestions.
49
+ - **Questions:** If you have questions or need assistance, the [getting help guide](https://nuxt.com/docs/community/getting-help) provides resources to help you out.
111
50
 
112
51
  ## Local Development
113
52
 
@@ -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 };
@@ -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.92e8ff32.mjs';
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';
@@ -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.92e8ff32.mjs';
2
- export { $ as $fetch, e as exposeContextToEnv, f as fetch, i as isDev, r as recoverContextFromEnv } from './shared/test-utils.92e8ff32.mjs';
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, ["dev"], {
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 < 50; 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.6.5",
3
+ "version": "3.7.1",
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.1.1",
25
- "get-port-please": "^3.0.1",
26
- "ofetch": "^1.1.1",
24
+ "execa": "^7.2.0",
25
+ "get-port-please": "^3.0.2",
26
+ "ofetch": "^1.3.3",
27
27
  "pathe": "^1.1.1",
28
- "ufo": "^1.1.2",
29
- "@nuxt/kit": "3.6.5",
30
- "@nuxt/schema": "3.6.5"
28
+ "ufo": "^1.3.0",
29
+ "@nuxt/kit": "3.7.1",
30
+ "@nuxt/schema": "3.7.1"
31
31
  },
32
32
  "devDependencies": {
33
- "@jest/globals": "29.6.0",
34
- "playwright-core": "1.35.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
  },