nuxt-spec 0.3.4 → 0.4.0-alpha.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/LICENSE +21 -21
- package/README.md +13 -13
- package/app/app.vue +10 -10
- package/app/components/NuxtSpecApiTestComponent.vue +24 -24
- package/app/components/NuxtSpecTestComponent.vue +9 -9
- package/app/components/index.d.ts +7 -7
- package/app/components/index.ts +2 -2
- package/app/utils/vitest-utils.ts +5 -5
- package/bin/_internal/prepublish-check.js +16 -16
- package/bin/cli.js +44 -44
- package/bin/helpers/commands.js +82 -82
- package/bin/setup.js +366 -287
- package/bin/update.js +94 -94
- package/config/index.d.ts +36 -33
- package/config/index.mjs +140 -132
- package/config/report/report-entry.html +6 -0
- package/config/report/report-head.html +34 -0
- package/{utils/screenshot/report-entry.html → config/report/report-screenshot.html} +8 -8
- package/config/report/report-tail.html +4 -0
- package/config/templates/pnpm-workspace.yaml.template +19 -19
- package/config/templates/vitest.config.ts.template +5 -5
- package/config/utils/merge.mjs +43 -43
- package/config/utils/options.d.mts +59 -0
- package/config/utils/options.mjs +116 -0
- package/config/utils/reporter.mjs +409 -0
- package/config/utils/warnings.mjs +38 -33
- package/modules/spec-options.ts +23 -0
- package/nuxt.config.ts +20 -24
- package/package.json +33 -31
- package/utils/e2e.ts +131 -131
- package/utils/helpers/check-params.ts +44 -41
- package/utils/helpers/location-hint.ts +30 -30
- package/utils/helpers/screenshot-utils.ts +27 -0
- package/utils/index.ts +12 -12
- package/utils/playwright.ts +28 -20
- package/utils/screenshot.ts +201 -172
- package/utils/screenshot/report-head.html +0 -24
- package/utils/screenshot/report-tail.html +0 -4
- package/utils/screenshot/report-utils.ts +0 -236
package/bin/update.js
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { execSync } from 'node:child_process'
|
|
4
|
-
import {
|
|
5
|
-
hasJsonKey, promptUser, showMessage,
|
|
6
|
-
} from 'elrh-cosca'
|
|
7
|
-
import {
|
|
8
|
-
getPlaywrightInstallCmd, getPrepareCmd, getUpdateCmd,
|
|
9
|
-
} from './helpers/commands.js'
|
|
10
|
-
|
|
11
|
-
const TARGET_VERSION = '0.
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* CLI tool to update existing `nuxt-spec` installation.
|
|
15
|
-
*
|
|
16
|
-
* It first asks whether to run in "auto" mode (no prompts, force = true) or "manual" mode (with prompts, force = false).
|
|
17
|
-
*
|
|
18
|
-
* Then it:
|
|
19
|
-
* 1) verifies `nuxt-spec` is present in `package.json` (fails with a hint to run `setup` otherwise)
|
|
20
|
-
* 2) runs the package manager's update command to bump `nuxt-spec` to the latest version
|
|
21
|
-
* 3) run the `nuxt prepare` command to regenerate types and auto-imports
|
|
22
|
-
* 4) run the `playwright install` command to ensure the Playwright browser runtimes are up to date
|
|
23
|
-
*
|
|
24
|
-
* @param {boolean} autoRun - Whether to run the update automatically without any prompts (defaults to false).
|
|
25
|
-
* @param {string} [packageManager] - Package manager to be used (`npm`, `pnpm`, `yarn`, `bun` or `deno`).
|
|
26
|
-
*/
|
|
27
|
-
export async function specUpdate(autoRun = false, packageManager) {
|
|
28
|
-
showMessage('NUXT SPEC UPDATE')
|
|
29
|
-
showMessage('This CLI tool will help you update Nuxt Spec in your project.')
|
|
30
|
-
showMessage('Refer to the documentation for more information.', 2)
|
|
31
|
-
|
|
32
|
-
// fail fast if there is nothing to update
|
|
33
|
-
const isInstalled = hasJsonKey('package.json', `dependencies.nuxt-spec`)
|
|
34
|
-
|| hasJsonKey('package.json', `devDependencies.nuxt-spec`)
|
|
35
|
-
if (!isInstalled) {
|
|
36
|
-
console.error(`'nuxt-spec' was not found in your 'package.json'. Run the 'setup' command first.`)
|
|
37
|
-
process.exit(1)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const isAutoRun = autoRun || await promptUser('Do you want to update everything automatically (no more prompts)?')
|
|
41
|
-
showMessage('')
|
|
42
|
-
|
|
43
|
-
// 1) run 'update nuxt-spec'
|
|
44
|
-
const updateCmd = getUpdateCmd(packageManager, `nuxt-spec@${TARGET_VERSION}`)
|
|
45
|
-
const runUpdate = isAutoRun || await promptUser(`This will bump 'nuxt-spec' to version '${TARGET_VERSION}' by running \`${updateCmd}\`. Continue?`)
|
|
46
|
-
if (runUpdate) {
|
|
47
|
-
try {
|
|
48
|
-
showMessage(`Running \`${updateCmd}\`...`)
|
|
49
|
-
execSync(updateCmd, { stdio: 'inherit' })
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.error(`Error running \`${updateCmd}\`:\n`, error.message)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 2) run 'nuxt prepare'
|
|
56
|
-
const prepareCmd = getPrepareCmd(packageManager)
|
|
57
|
-
const runPrepare = isAutoRun || await promptUser(`Nuxt types and auto-imports should be regenerated after the update. Do you want to run \`${prepareCmd}\` now?`)
|
|
58
|
-
if (runPrepare) {
|
|
59
|
-
try {
|
|
60
|
-
showMessage(`Running \`${prepareCmd}\`...`)
|
|
61
|
-
execSync(prepareCmd, { stdio: 'inherit' })
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error(`Error running \`${prepareCmd}\`:\n`, error.message)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// 3) run 'playwright install'
|
|
68
|
-
const playwrightUpdateCmd = getPlaywrightInstallCmd(packageManager)
|
|
69
|
-
const runPlaywrightUpdate = isAutoRun || await promptUser(`Playwright browser runtimes might need to be updated for e2e tests. Do you want to run \`${playwrightUpdateCmd}\` now?`)
|
|
70
|
-
if (runPlaywrightUpdate) {
|
|
71
|
-
try {
|
|
72
|
-
showMessage(`Running \`${playwrightUpdateCmd}\`...`)
|
|
73
|
-
execSync(playwrightUpdateCmd, { stdio: 'inherit' })
|
|
74
|
-
} catch (error) {
|
|
75
|
-
console.error(`Error running \`${playwrightUpdateCmd}\`:\n`, error.message)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 4) inform user
|
|
80
|
-
showMessage('')
|
|
81
|
-
showMessage('NUXT SPEC UPDATE COMPLETE', 2)
|
|
82
|
-
if (!runUpdate) {
|
|
83
|
-
showMessage(`Run \`${updateCmd}\` to update 'nuxt-spec'.`)
|
|
84
|
-
}
|
|
85
|
-
if (!runPrepare) {
|
|
86
|
-
showMessage(`Run \`${prepareCmd}\` to regenerate the Nuxt types and auto-imports.`)
|
|
87
|
-
}
|
|
88
|
-
if (!runPlaywrightUpdate) {
|
|
89
|
-
showMessage(`Run \`${playwrightUpdateCmd}\` to update the Playwright browser runtimes for e2e tests.`)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// force exit to prevent #20
|
|
93
|
-
process.exit(0)
|
|
94
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'node:child_process'
|
|
4
|
+
import {
|
|
5
|
+
hasJsonKey, promptUser, showMessage,
|
|
6
|
+
} from 'elrh-cosca'
|
|
7
|
+
import {
|
|
8
|
+
getPlaywrightInstallCmd, getPrepareCmd, getUpdateCmd,
|
|
9
|
+
} from './helpers/commands.js'
|
|
10
|
+
|
|
11
|
+
const TARGET_VERSION = '0.4.0-alpha.1'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* CLI tool to update existing `nuxt-spec` installation.
|
|
15
|
+
*
|
|
16
|
+
* It first asks whether to run in "auto" mode (no prompts, force = true) or "manual" mode (with prompts, force = false).
|
|
17
|
+
*
|
|
18
|
+
* Then it:
|
|
19
|
+
* 1) verifies `nuxt-spec` is present in `package.json` (fails with a hint to run `setup` otherwise)
|
|
20
|
+
* 2) runs the package manager's update command to bump `nuxt-spec` to the latest version
|
|
21
|
+
* 3) run the `nuxt prepare` command to regenerate types and auto-imports
|
|
22
|
+
* 4) run the `playwright install` command to ensure the Playwright browser runtimes are up to date
|
|
23
|
+
*
|
|
24
|
+
* @param {boolean} autoRun - Whether to run the update automatically without any prompts (defaults to false).
|
|
25
|
+
* @param {string} [packageManager] - Package manager to be used (`npm`, `pnpm`, `yarn`, `bun` or `deno`).
|
|
26
|
+
*/
|
|
27
|
+
export async function specUpdate(autoRun = false, packageManager) {
|
|
28
|
+
showMessage({ message: 'NUXT SPEC UPDATE' })
|
|
29
|
+
showMessage({ message: 'This CLI tool will help you update Nuxt Spec in your project.' })
|
|
30
|
+
showMessage({ message: 'Refer to the documentation for more information.', linesAfter: 2 })
|
|
31
|
+
|
|
32
|
+
// fail fast if there is nothing to update
|
|
33
|
+
const isInstalled = hasJsonKey({ targetFile: 'package.json', jsonKey: `dependencies.nuxt-spec` })
|
|
34
|
+
|| hasJsonKey({ targetFile: 'package.json', jsonKey: `devDependencies.nuxt-spec` })
|
|
35
|
+
if (!isInstalled) {
|
|
36
|
+
console.error(`[Nuxt Spec] 'nuxt-spec' was not found in your 'package.json'. Run the 'setup' command first.`)
|
|
37
|
+
process.exit(1)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const isAutoRun = autoRun || await promptUser({ question: '[Nuxt Spec] Do you want to update everything automatically (no more prompts)?' })
|
|
41
|
+
showMessage({ message: '' })
|
|
42
|
+
|
|
43
|
+
// 1) run 'update nuxt-spec'
|
|
44
|
+
const updateCmd = getUpdateCmd(packageManager, `nuxt-spec@${TARGET_VERSION}`)
|
|
45
|
+
const runUpdate = isAutoRun || await promptUser({ question: `[Nuxt Spec] This will bump 'nuxt-spec' to version '${TARGET_VERSION}' by running \`${updateCmd}\`. Continue?` })
|
|
46
|
+
if (runUpdate) {
|
|
47
|
+
try {
|
|
48
|
+
showMessage({ message: `Running \`${updateCmd}\`...` })
|
|
49
|
+
execSync(updateCmd, { stdio: 'inherit' })
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(`[Nuxt Spec] Error running \`${updateCmd}\`:\n`, error.message)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// 2) run 'nuxt prepare'
|
|
56
|
+
const prepareCmd = getPrepareCmd(packageManager)
|
|
57
|
+
const runPrepare = isAutoRun || await promptUser({ question: `[Nuxt Spec] Nuxt types and auto-imports should be regenerated after the update. Do you want to run \`${prepareCmd}\` now?` })
|
|
58
|
+
if (runPrepare) {
|
|
59
|
+
try {
|
|
60
|
+
showMessage({ message: `Running \`${prepareCmd}\`...` })
|
|
61
|
+
execSync(prepareCmd, { stdio: 'inherit' })
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(`[Nuxt Spec] Error running \`${prepareCmd}\`:\n`, error.message)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 3) run 'playwright install'
|
|
68
|
+
const playwrightUpdateCmd = getPlaywrightInstallCmd(packageManager)
|
|
69
|
+
const runPlaywrightUpdate = isAutoRun || await promptUser({ question: `[Nuxt Spec] Playwright browser runtimes might need to be updated for e2e tests. Do you want to run \`${playwrightUpdateCmd}\` now?` })
|
|
70
|
+
if (runPlaywrightUpdate) {
|
|
71
|
+
try {
|
|
72
|
+
showMessage({ message: `Running \`${playwrightUpdateCmd}\`...` })
|
|
73
|
+
execSync(playwrightUpdateCmd, { stdio: 'inherit' })
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error(`[Nuxt Spec] Error running \`${playwrightUpdateCmd}\`:\n`, error.message)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 4) inform user
|
|
80
|
+
showMessage({ message: '' })
|
|
81
|
+
showMessage({ message: 'NUXT SPEC UPDATE COMPLETE', linesAfter: 2 })
|
|
82
|
+
if (!runUpdate) {
|
|
83
|
+
showMessage({ message: `Run \`${updateCmd}\` to update 'nuxt-spec'.` })
|
|
84
|
+
}
|
|
85
|
+
if (!runPrepare) {
|
|
86
|
+
showMessage({ message: `Run \`${prepareCmd}\` to regenerate the Nuxt types and auto-imports.` })
|
|
87
|
+
}
|
|
88
|
+
if (!runPlaywrightUpdate) {
|
|
89
|
+
showMessage({ message: `Run \`${playwrightUpdateCmd}\` to update the Playwright browser runtimes for e2e tests.` })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// force exit to prevent #20
|
|
93
|
+
process.exit(0)
|
|
94
|
+
}
|
package/config/index.d.ts
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import type { UserConfig } from 'vite'
|
|
2
|
-
import type { TestUserConfig } from 'vitest/config'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import type { UserConfig } from 'vite'
|
|
2
|
+
import type { TestUserConfig } from 'vitest/config'
|
|
3
|
+
|
|
4
|
+
export type { HtmlReportOpenMode, NuxtSpecOptions } from './utils/options.mjs'
|
|
5
|
+
|
|
6
|
+
/** Typed Vite configuration object for tests */
|
|
7
|
+
type ExtendedUserConfig = UserConfig & {
|
|
8
|
+
test?: TestUserConfig
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Allows fine-grained control over default Vitest `projects`.
|
|
13
|
+
*
|
|
14
|
+
* By default, everything is included.
|
|
15
|
+
* If set to `false`, `test.projects` key is not merged at all.
|
|
16
|
+
* If set to object, specific projects can be omitted by setting respective key to `false`.
|
|
17
|
+
*/
|
|
18
|
+
type ProjectsConfig = boolean | {
|
|
19
|
+
default?: boolean
|
|
20
|
+
unit?: boolean
|
|
21
|
+
nuxt?: boolean
|
|
22
|
+
e2e?: boolean
|
|
23
|
+
browser?: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Prepare Vitest configuration object - user config merged with nuxt-spec defaults
|
|
28
|
+
* (defaults are adjusted by `spec` key from nuxt.config.ts and NUXT_SPEC_* env variables)
|
|
29
|
+
* @param userVitestConfig - custom Vitest config passed from the user
|
|
30
|
+
* @param projects - allows fine-grained control over default `test.projects` - see `ProjectsConfig` for details
|
|
31
|
+
* @returns Promise resolving to defu-merged Vitest configuration
|
|
32
|
+
*/
|
|
33
|
+
export declare function loadVitestConfig(
|
|
34
|
+
userVitestConfig: ExtendedUserConfig,
|
|
35
|
+
projects?: ProjectsConfig,
|
|
36
|
+
): Promise<ExtendedUserConfig>
|
package/config/index.mjs
CHANGED
|
@@ -1,132 +1,140 @@
|
|
|
1
|
-
// this is the default Vitest config object
|
|
2
|
-
// based on https://nuxt.com/docs/4.x/getting-started/testing#setup
|
|
3
|
-
// `projects=false` can be used to suspend the default usage of "projects" in Vitest config
|
|
4
|
-
|
|
5
|
-
import { availableParallelism } from 'node:os'
|
|
6
|
-
import { fileURLToPath } from 'node:url'
|
|
7
|
-
import { onConsoleLog } from './utils/warnings.mjs' // filter out unnecessary logs
|
|
8
|
-
import { mergeConfig } from './utils/merge.mjs' // defu-based merge function
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
1
|
+
// this is the default Vitest config object
|
|
2
|
+
// based on https://nuxt.com/docs/4.x/getting-started/testing#setup
|
|
3
|
+
// `projects=false` can be used to suspend the default usage of "projects" in Vitest config
|
|
4
|
+
|
|
5
|
+
import { availableParallelism } from 'node:os'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
import { addMessageFilters, onConsoleLog } from './utils/warnings.mjs' // filter out unnecessary logs
|
|
8
|
+
import { mergeConfig } from './utils/merge.mjs' // defu-based merge function
|
|
9
|
+
import { loadSpecOptions } from './utils/options.mjs' // `spec` key from nuxt.config.ts + NUXT_SPEC_* env variables
|
|
10
|
+
import { nuxtSpecReportPlugin } from './utils/reporter.mjs' // HTML test report
|
|
11
|
+
import { defineConfig } from 'vitest/config'
|
|
12
|
+
import { defineVitestProject } from '@nuxt/test-utils/config'
|
|
13
|
+
import { playwright } from '@vitest/browser-playwright'
|
|
14
|
+
import vue from '@vitejs/plugin-vue'
|
|
15
|
+
|
|
16
|
+
// absolute paths so it works from within the nuxt-ignis package
|
|
17
|
+
const externalPlaywrightSetup = fileURLToPath(new URL('../utils/playwright.ts', import.meta.url))
|
|
18
|
+
|
|
19
|
+
export async function loadVitestConfig(userVitestConfig, projects = true) {
|
|
20
|
+
const { externalPlaywright, htmlReport, messageFilters } = await loadSpecOptions()
|
|
21
|
+
|
|
22
|
+
// extend array of messages that will be filtered out from the output
|
|
23
|
+
// with values passed by the user (if any)
|
|
24
|
+
addMessageFilters(messageFilters)
|
|
25
|
+
|
|
26
|
+
const baseConfig = {
|
|
27
|
+
test: {
|
|
28
|
+
// filter-out unnecessary console logs coming from Vitest
|
|
29
|
+
// when the import is resolved, unnecessary stderr logs are also filtered-out
|
|
30
|
+
// as a side-effect
|
|
31
|
+
onConsoleLog,
|
|
32
|
+
// Vitest defaults to 5 which might be unnecessarily restrictive
|
|
33
|
+
// if the host machine can support more
|
|
34
|
+
maxConcurrency: availableParallelism() / 2,
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// HTML test report for all projects
|
|
39
|
+
// report is generated unless explicitly disabled
|
|
40
|
+
if (htmlReport.enabled) {
|
|
41
|
+
baseConfig.plugins = [nuxtSpecReportPlugin({ open: htmlReport.open })]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// add proposed projects settings
|
|
45
|
+
// user can control the inclusion via `projects: ProjectsConfig` config object
|
|
46
|
+
// projects are included by default unless explicitly disabled
|
|
47
|
+
if (projects !== false) {
|
|
48
|
+
baseConfig.test.projects = []
|
|
49
|
+
|
|
50
|
+
// default fallback to catch tests directly in /test folder
|
|
51
|
+
if (projects.default !== false) {
|
|
52
|
+
baseConfig.test.projects.push({
|
|
53
|
+
extends: true,
|
|
54
|
+
test: {
|
|
55
|
+
name: 'default',
|
|
56
|
+
include: ['{test,tests}/**/*.{test,spec}.ts', '!test/{browser,e2e,nuxt,unit}/**'],
|
|
57
|
+
environment: 'node',
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// proposed setup for Unit tests
|
|
63
|
+
if (projects.unit !== false) {
|
|
64
|
+
baseConfig.test.projects.push({
|
|
65
|
+
extends: true,
|
|
66
|
+
test: {
|
|
67
|
+
name: 'unit',
|
|
68
|
+
include: ['test/unit/**/*.{test,spec}.ts'],
|
|
69
|
+
environment: 'node',
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// proposed setup for Nuxt component tests
|
|
75
|
+
if (projects.nuxt !== false) {
|
|
76
|
+
baseConfig.test.projects.push(
|
|
77
|
+
await defineVitestProject({
|
|
78
|
+
extends: true,
|
|
79
|
+
test: {
|
|
80
|
+
name: 'nuxt',
|
|
81
|
+
include: ['test/nuxt/**/*.{test,spec}.ts'],
|
|
82
|
+
environment: 'nuxt',
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// proposed setup for classic E2E tests (node-based, using @nuxt/test-utils)
|
|
89
|
+
if (projects.e2e !== false) {
|
|
90
|
+
baseConfig.test.projects.push({
|
|
91
|
+
extends: true,
|
|
92
|
+
test: {
|
|
93
|
+
name: 'e2e',
|
|
94
|
+
include: ['test/e2e/**/*.{test,spec}.ts'],
|
|
95
|
+
environment: 'node',
|
|
96
|
+
// allows connecting to an external Playwright instance (if configured)
|
|
97
|
+
setupFiles: externalPlaywright ? [externalPlaywrightSetup] : [],
|
|
98
|
+
// setup file will just read the value via `inject()`
|
|
99
|
+
provide: externalPlaywright ? { nuxtSpecExternalPlaywright: externalPlaywright } : {},
|
|
100
|
+
},
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// proposed setup for browser component tests (with Playwright runner)
|
|
105
|
+
if (projects.browser !== false) {
|
|
106
|
+
// allows connecting to an external Playwright instance (if configured)
|
|
107
|
+
const playwrightConfig = {}
|
|
108
|
+
if (externalPlaywright) {
|
|
109
|
+
console.log(`[Nuxt Spec] Using external Playwright instance for browser tests at: ${externalPlaywright}`)
|
|
110
|
+
playwrightConfig.connectOptions = {
|
|
111
|
+
wsEndpoint: externalPlaywright,
|
|
112
|
+
// this allows reaching caller's localhost from within the external Playwright
|
|
113
|
+
exposeNetwork: '<loopback>',
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
baseConfig.test.projects.push({
|
|
117
|
+
extends: true,
|
|
118
|
+
// vue plugin is required for proper imports resolution
|
|
119
|
+
plugins: [vue()],
|
|
120
|
+
test: {
|
|
121
|
+
name: 'browser',
|
|
122
|
+
include: ['test/browser/**/*.{test,spec}.ts'],
|
|
123
|
+
environment: 'node',
|
|
124
|
+
// only chromium browser by default - add others manually if needed
|
|
125
|
+
browser: {
|
|
126
|
+
provider: playwright(playwrightConfig),
|
|
127
|
+
enabled: true,
|
|
128
|
+
headless: true,
|
|
129
|
+
instances: [{
|
|
130
|
+
browser: 'chromium',
|
|
131
|
+
viewport: { width: 1280, height: 720 },
|
|
132
|
+
}],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
})
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return mergeConfig(userVitestConfig, defineConfig(baseConfig))
|
|
140
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Nuxt Spec Test Report - {{TIMESTAMP}}</title>
|
|
6
|
+
<style>
|
|
7
|
+
body { font-family: system-ui, sans-serif; margin: 2rem; background: #f5f5f5; color: #222; }
|
|
8
|
+
h1 { font-size: 1.4rem; }
|
|
9
|
+
.summary { font-weight: 700; font-size: 18px; }
|
|
10
|
+
.summary.passed { color: #0b0; }
|
|
11
|
+
.summary.failed { color: #b00; }
|
|
12
|
+
.failure { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 1rem; margin: 1rem 0; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
|
|
13
|
+
.failure h2 { font-size: 1rem; margin: 0 0 .25rem; }
|
|
14
|
+
.failure .location { color: #666; font-size: .8rem; margin: 0 0 .75rem; }
|
|
15
|
+
.failure pre { white-space: pre-wrap; word-break: break-word; font-size: .8rem; margin: 0 0 .75rem; padding: .5rem; background: #fafafa; border: 1px solid #eee; border-radius: 4px; }
|
|
16
|
+
.failure pre.message { color: #b00; }
|
|
17
|
+
.failure details summary { cursor: pointer; font-size: .8rem; margin-bottom: .25rem; }
|
|
18
|
+
.screenshot { margin-top: .75rem; }
|
|
19
|
+
.screenshot h3 { font-size: .9rem; margin: 0 0 .25rem; }
|
|
20
|
+
.screenshot .message { color: #b00; font-size: .85rem; margin: 0 0 .75rem; }
|
|
21
|
+
.pair { display: flex; gap: 1rem; flex-wrap: wrap; }
|
|
22
|
+
.pair figure { margin: 0; flex: 1 1 0; min-width: 240px; }
|
|
23
|
+
.pair figcaption { font-size: .8rem; margin-bottom: .25rem; font-weight: bold; }
|
|
24
|
+
.pair figure:first-child figcaption { color: #0b0; }
|
|
25
|
+
.pair figure:last-child figcaption { color: #b00; }
|
|
26
|
+
.pair img { max-width: 100%; background: #fff; }
|
|
27
|
+
.pair figure:first-child img { border: 2px solid #0b0; }
|
|
28
|
+
.pair figure:last-child img { border: 2px solid #b00; }
|
|
29
|
+
</style>
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
<h1>Nuxt Spec Test Report - {{TIMESTAMP}}</h1>
|
|
33
|
+
<p class="summary {{STATUS}}">{{SUMMARY}}</p>
|
|
34
|
+
<!-- BEGIN failure entries -->
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<div class="
|
|
2
|
-
<
|
|
3
|
-
<p class="message">{{MESSAGE}}</p>
|
|
4
|
-
<div class="pair">
|
|
5
|
-
<figure><figcaption>Baseline image</figcaption><img src="{{BASELINE_URI}}" alt="Baseline image for reference"></figure>
|
|
6
|
-
<figure><figcaption>Actual screenshot</figcaption><img src="{{ACTUAL_URI}}" alt="Actual screenshot taken"></figure>
|
|
7
|
-
</div>
|
|
8
|
-
</div>
|
|
1
|
+
<div class="screenshot">
|
|
2
|
+
<h3>{{FILE_NAME}}</h3>
|
|
3
|
+
<p class="message">{{MESSAGE}}</p>
|
|
4
|
+
<div class="pair">
|
|
5
|
+
<figure><figcaption>Baseline image</figcaption><img src="{{BASELINE_URI}}" alt="Baseline image for reference"></figure>
|
|
6
|
+
<figure><figcaption>Actual screenshot</figcaption><img src="{{ACTUAL_URI}}" alt="Actual screenshot taken"></figure>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# settings for Nuxt & pnpm
|
|
2
|
-
|
|
3
|
-
# https://pnpm.io/settings/node-modules#shamefullyhoist
|
|
4
|
-
# required to handle transitive dependencies
|
|
5
|
-
# without having to explicitly declare them
|
|
6
|
-
shamefullyHoist: true
|
|
7
|
-
|
|
8
|
-
# https://pnpm.io/settings/build#allowbuilds
|
|
9
|
-
# pnpm naturally blocks all post-install scripts
|
|
10
|
-
# some are required for development, others are not relevant
|
|
11
|
-
allowBuilds:
|
|
12
|
-
# provides fallback repair of platform-specific Rust native engine
|
|
13
|
-
'unrs-resolver': true
|
|
14
|
-
# allows node-gyp build of associated native binaries from local sources
|
|
15
|
-
# disabled because it would require an explicit opt-in
|
|
16
|
-
'@parcel/watcher': false
|
|
17
|
-
# optimization for CLI usage of 'esbuild'
|
|
18
|
-
# disabled because its runtime resolves native binaries itself
|
|
19
|
-
'esbuild': false
|
|
1
|
+
# settings for Nuxt & pnpm
|
|
2
|
+
|
|
3
|
+
# https://pnpm.io/settings/node-modules#shamefullyhoist
|
|
4
|
+
# required to handle transitive dependencies
|
|
5
|
+
# without having to explicitly declare them
|
|
6
|
+
shamefullyHoist: true
|
|
7
|
+
|
|
8
|
+
# https://pnpm.io/settings/build#allowbuilds
|
|
9
|
+
# pnpm naturally blocks all post-install scripts
|
|
10
|
+
# some are required for development, others are not relevant
|
|
11
|
+
allowBuilds:
|
|
12
|
+
# provides fallback repair of platform-specific Rust native engine
|
|
13
|
+
'unrs-resolver': true
|
|
14
|
+
# allows node-gyp build of associated native binaries from local sources
|
|
15
|
+
# disabled because it would require an explicit opt-in
|
|
16
|
+
'@parcel/watcher': false
|
|
17
|
+
# optimization for CLI usage of 'esbuild'
|
|
18
|
+
# disabled because its runtime resolves native binaries itself
|
|
19
|
+
'esbuild': false
|