nuxt-spec 0.2.0-alpha.9 → 0.2.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 +5 -5
- package/bin/setup.js +9 -9
- package/config/utils/warnings.mjs +7 -1
- package/nuxt.config.ts +19 -0
- package/package.json +16 -28
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ If you don't want to use the CLI tool, or you want to understand its flow better
|
|
|
37
37
|
1) Add following dependency into your `package.json`:
|
|
38
38
|
|
|
39
39
|
```
|
|
40
|
-
"nuxt-spec": "0.2.
|
|
40
|
+
"nuxt-spec": "0.2.1"
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
2) Add following section into your `nuxt.config.ts`:
|
|
@@ -89,7 +89,7 @@ test/
|
|
|
89
89
|
└── vitest-unit.test.ts
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
-
You can use sample files from the [project repository](https://github.com/AloisSeckar/nuxt-spec/tree/v0.2.
|
|
92
|
+
You can use sample files from the [project repository](https://github.com/AloisSeckar/nuxt-spec/tree/v0.2.1/test).
|
|
93
93
|
|
|
94
94
|
### Install and execute
|
|
95
95
|
|
|
@@ -249,11 +249,11 @@ Planned future development:
|
|
|
249
249
|
- reason about (not) using Vitest browser mode (or make it optional)
|
|
250
250
|
- solution for visual regression testing - (currently there is experimental custom solution)
|
|
251
251
|
|
|
252
|
-
See [CHANGELOG.md](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.
|
|
252
|
+
See [CHANGELOG.md](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.1/CHANGELOG.md) for the latest updates and features.
|
|
253
253
|
|
|
254
254
|
## Configuration
|
|
255
255
|
|
|
256
|
-
By default, `nuxt-spec` uses Vitest configuration defined in [`/config/index.mjs`](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.
|
|
256
|
+
By default, `nuxt-spec` uses Vitest configuration defined in [`/config/index.mjs`](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.1/config/index.mjs). The configuration is based on [Nuxt team recommendations](https://nuxt.com/docs/4.x/getting-started/testing) and our best judgement.
|
|
257
257
|
|
|
258
258
|
To add/override your custom config, you can create (or scaffold via CLI tool) a file named `vitest.config.ts` in the root of your project with the following content:
|
|
259
259
|
|
|
@@ -357,7 +357,7 @@ const html: string = await getAPIResultHtml('/', '#api-fetch', '/your-api', '#ap
|
|
|
357
357
|
const html: string = await getAPIResultHtml(page, '#api-fetch', '/your-api', '#api-result')
|
|
358
358
|
```
|
|
359
359
|
|
|
360
|
-
For detailed description, see [utils.d.ts](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.
|
|
360
|
+
For detailed description, see [utils.d.ts](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.1/utils/index.d.ts).
|
|
361
361
|
|
|
362
362
|
## Contact
|
|
363
363
|
|
package/bin/setup.js
CHANGED
|
@@ -37,7 +37,7 @@ export async function specSetup(autoRun = false) {
|
|
|
37
37
|
// add nuxt-spec
|
|
38
38
|
try {
|
|
39
39
|
await updateJsonFile('package.json', 'dependencies', {
|
|
40
|
-
'nuxt-spec': '0.2.
|
|
40
|
+
'nuxt-spec': '0.2.1',
|
|
41
41
|
}, isAutoRun, 'This will add \'nuxt-spec\' dependency to your \'package.json\'. Continue?')
|
|
42
42
|
} catch (error) {
|
|
43
43
|
console.error('Error adding \'nuxt-spec\' dependency:\n', error.message)
|
|
@@ -105,9 +105,9 @@ export async function specSetup(autoRun = false) {
|
|
|
105
105
|
if (packageManager === 'pnpm') {
|
|
106
106
|
try {
|
|
107
107
|
if (pathExists('pnpm-workspace.yaml')) {
|
|
108
|
-
await updateTextFile('pnpm-workspace.yaml', ['shamefully-hoist
|
|
108
|
+
await updateTextFile('pnpm-workspace.yaml', ['shamefully-hoist: true'], isAutoRun, 'This will adjust \'pnpm-workspace.yaml\' file in your project. Continue?')
|
|
109
109
|
} else {
|
|
110
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.
|
|
110
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.1/config/templates/pnpm-workspace.yaml.template',
|
|
111
111
|
'pnpm-workspace.yaml', isAutoRun, 'This will add \'pnpm-workspace.yaml\' file for your project. Continue?')
|
|
112
112
|
}
|
|
113
113
|
} catch (error) {
|
|
@@ -117,7 +117,7 @@ export async function specSetup(autoRun = false) {
|
|
|
117
117
|
|
|
118
118
|
// 4) create vitest.config.ts
|
|
119
119
|
try {
|
|
120
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.
|
|
120
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.1/config/templates/vitest.config.ts.template',
|
|
121
121
|
'vitest.config.ts', isAutoRun, 'This will create a new \'vitest.config.ts\' file for your project. Continue?')
|
|
122
122
|
} catch (error) {
|
|
123
123
|
console.error('Error setting up \'vitest.config.ts\':\n', error.message)
|
|
@@ -155,31 +155,31 @@ export async function specSetup(autoRun = false) {
|
|
|
155
155
|
const createSampleTests = isAutoRun || await promptUser('Do you want to create sample tests in \'/test\' folder?')
|
|
156
156
|
if (createSampleTests) {
|
|
157
157
|
try {
|
|
158
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.
|
|
158
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.1/test/browser/vitest-browser.test.ts',
|
|
159
159
|
'test/browser/vitest-browser.test.ts', true)
|
|
160
160
|
} catch (error) {
|
|
161
161
|
console.error('Error setting up \'vitest-browser.test.ts\':\n', error.message)
|
|
162
162
|
}
|
|
163
163
|
try {
|
|
164
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.
|
|
164
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.1/test/e2e/nuxt-e2e.test.ts',
|
|
165
165
|
'test/e2e/nuxt-e2e.test.ts', true)
|
|
166
166
|
} catch (error) {
|
|
167
167
|
console.error('Error setting up \'nuxt-e2e.test.ts\':\n', error.message)
|
|
168
168
|
}
|
|
169
169
|
try {
|
|
170
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.
|
|
170
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.1/test/e2e/nuxt-visual.test.ts',
|
|
171
171
|
'test/e2e/nuxt-visual.test.ts', true)
|
|
172
172
|
} catch (error) {
|
|
173
173
|
console.error('Error setting up \'nuxt-visual.test.ts\':\n', error.message)
|
|
174
174
|
}
|
|
175
175
|
try {
|
|
176
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.
|
|
176
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.1/test/nuxt/nuxt-unit.test.ts',
|
|
177
177
|
'test/nuxt/nuxt-unit.test.ts', true)
|
|
178
178
|
} catch (error) {
|
|
179
179
|
console.error('Error setting up \'nuxt-unit.test.ts\':\n', error.message)
|
|
180
180
|
}
|
|
181
181
|
try {
|
|
182
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.
|
|
182
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.1/test/unit/vitest-unit.test.ts',
|
|
183
183
|
'test/unit/vitest-unit.test.ts', true)
|
|
184
184
|
} catch (error) {
|
|
185
185
|
console.error('Error setting up \'vitest-unit.test.ts\':\n', error.message)
|
|
@@ -9,7 +9,7 @@ const messageFilters = [
|
|
|
9
9
|
'<Suspense> is an experimental feature',
|
|
10
10
|
]
|
|
11
11
|
|
|
12
|
-
// 1) filter-out unnecessary stderr logs coming from Vitest
|
|
12
|
+
// 1) filter-out unnecessary stderr/stdout logs coming from Vitest
|
|
13
13
|
// (applied as side-effect on import)
|
|
14
14
|
|
|
15
15
|
const _stderrWrite = process.stderr.write.bind(process.stderr)
|
|
@@ -18,6 +18,12 @@ process.stderr.write = (chunk, ...args) => {
|
|
|
18
18
|
return _stderrWrite(chunk, ...args)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const _stdoutWrite = process.stdout.write.bind(process.stdout)
|
|
22
|
+
process.stdout.write = (chunk, ...args) => {
|
|
23
|
+
if (typeof chunk === 'string' && messageFilters.some(f => chunk.includes(f))) return true
|
|
24
|
+
return _stdoutWrite(chunk, ...args)
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
// 2) filter-out unnecessary console logs coming from Vitest
|
|
22
28
|
// (used as Vitest onConsoleLog hook)
|
|
23
29
|
|
package/nuxt.config.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default defineNuxtConfig({
|
|
2
|
+
modules: [
|
|
3
|
+
'@nuxt/eslint',
|
|
4
|
+
'@nuxt/test-utils/module',
|
|
5
|
+
],
|
|
6
|
+
|
|
7
|
+
// exclude file used for explicit exports (nuxt-spec/components) from Nuxt resolution
|
|
8
|
+
components: {
|
|
9
|
+
dirs: [{ path: '~/components', ignore: ['index.ts'] }],
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
compatibilityDate: '2026-03-15',
|
|
13
|
+
|
|
14
|
+
eslint: {
|
|
15
|
+
config: {
|
|
16
|
+
stylistic: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-spec",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Test-pack layer for Nuxt Applications",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,19 +9,6 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"main": "./nuxt.config.ts",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"analyze": "nuxt analyze",
|
|
14
|
-
"eslint": "eslint .",
|
|
15
|
-
"build": "pnpm test && nuxt build",
|
|
16
|
-
"dev": "nuxt dev",
|
|
17
|
-
"generate": "nuxt generate",
|
|
18
|
-
"prepublishOnly": "pnpm build",
|
|
19
|
-
"preview": "nuxt preview",
|
|
20
|
-
"start": "nuxt start",
|
|
21
|
-
"test": "vitest run",
|
|
22
|
-
"test-u": "vitest run -u",
|
|
23
|
-
"test-i": "vitest"
|
|
24
|
-
},
|
|
25
12
|
"bin": {
|
|
26
13
|
"nuxt-spec": "bin/cli.js"
|
|
27
14
|
},
|
|
@@ -47,7 +34,8 @@
|
|
|
47
34
|
"bin",
|
|
48
35
|
"config",
|
|
49
36
|
"public",
|
|
50
|
-
"utils"
|
|
37
|
+
"utils",
|
|
38
|
+
"nuxt.config.ts"
|
|
51
39
|
],
|
|
52
40
|
"dependencies": {
|
|
53
41
|
"@nuxt/eslint": "1.15.2",
|
|
@@ -69,16 +57,16 @@
|
|
|
69
57
|
"vue": "3.5.30",
|
|
70
58
|
"vue-router": "5.0.3"
|
|
71
59
|
},
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
60
|
+
"scripts": {
|
|
61
|
+
"analyze": "nuxt analyze",
|
|
62
|
+
"eslint": "eslint .",
|
|
63
|
+
"build": "pnpm test && nuxt build",
|
|
64
|
+
"dev": "nuxt dev",
|
|
65
|
+
"generate": "nuxt generate",
|
|
66
|
+
"preview": "nuxt preview",
|
|
67
|
+
"start": "nuxt start",
|
|
68
|
+
"test": "vitest run",
|
|
69
|
+
"test-u": "vitest run -u",
|
|
70
|
+
"test-i": "vitest"
|
|
71
|
+
}
|
|
72
|
+
}
|