nuxt-spec 0.1.16 → 0.1.18
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 +10 -9
- package/bin/setup.js +6 -6
- package/config/index.mjs +4 -4
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ If you don't want to use the CLI tool, or you want to understand its flow better
|
|
|
36
36
|
1) Add following dependency into your `package.json`:
|
|
37
37
|
|
|
38
38
|
```
|
|
39
|
-
"nuxt-spec": "0.1.
|
|
39
|
+
"nuxt-spec": "0.1.18"
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
2) Add following section into your `nuxt.config.ts`:
|
|
@@ -85,7 +85,7 @@ test/
|
|
|
85
85
|
└── vitest.test.ts
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
You can use sample files from the [project repository](https://github.com/AloisSeckar/nuxt-spec/tree/v0.1.
|
|
88
|
+
You can use sample files from the [project repository](https://github.com/AloisSeckar/nuxt-spec/tree/v0.1.18/test).
|
|
89
89
|
|
|
90
90
|
### Install and execute
|
|
91
91
|
|
|
@@ -244,11 +244,11 @@ Planned future development:
|
|
|
244
244
|
- reason about (not) using Vitest browser mode (or make it optional)
|
|
245
245
|
- solution for visual testing - either [backstopjs](https://www.npmjs.com/package/backstopjs) or Vitest's native (currently experimental)
|
|
246
246
|
|
|
247
|
-
See [CHANGELOG.md](https://github.com/AloisSeckar/nuxt-spec/blob/v0.1.
|
|
247
|
+
See [CHANGELOG.md](https://github.com/AloisSeckar/nuxt-spec/blob/v0.1.18/CHANGELOG.md) for the latest updates and features.
|
|
248
248
|
|
|
249
249
|
## Configuration
|
|
250
250
|
|
|
251
|
-
By default, `nuxt-spec` uses Vitest configuration defined in [`/config/index.mjs`](https://github.com/AloisSeckar/nuxt-spec/blob/v0.1.
|
|
251
|
+
By default, `nuxt-spec` uses Vitest configuration defined in [`/config/index.mjs`](https://github.com/AloisSeckar/nuxt-spec/blob/v0.1.18/config/index.mjs). The configuration is based on [Nuxt team recommendations](https://nuxt.com/docs/4.x/getting-started/testing) and our best judgement.
|
|
252
252
|
|
|
253
253
|
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:
|
|
254
254
|
|
|
@@ -274,12 +274,13 @@ export default loadVitestConfig({
|
|
|
274
274
|
})
|
|
275
275
|
```
|
|
276
276
|
|
|
277
|
-
By default, Nuxt Spec built-in configuration establishes 3 `projects
|
|
278
|
-
- `unit` - for unit tests in `test/unit
|
|
279
|
-
- `nuxt` - for Nuxt-related tests in `test/nuxt
|
|
280
|
-
- `e2e` - for end-to-end tests in `test/e2e
|
|
277
|
+
By default, Nuxt Spec built-in configuration establishes 3 `projects` + one fallback:
|
|
278
|
+
- `unit` - for unit tests in `test/unit/**` - env is set to `node`
|
|
279
|
+
- `nuxt` - for Nuxt-related tests in `test/nuxt/**` - env is set to `nuxt`
|
|
280
|
+
- `e2e` - for end-to-end tests in `test/e2e/**` - env is set to `node`
|
|
281
|
+
- `default` - fallback for all other tests in `test/**` and/or `tests/**` directories - env is set to `node`
|
|
281
282
|
|
|
282
|
-
Vitest will then expects at least one test defined in
|
|
283
|
+
Vitest will then expects at least one test defined in either of those directories. The `test.projects` confing may be extended with others, but it cannot be easily removed due to nature of defu-merge process. If your project uses different configuration (i.e. your test reside in completely different path), you can pass `false` as a second parameter to `loadVitestConfig()` function to exclude `test.projects` key to be injected:
|
|
283
284
|
|
|
284
285
|
```ts
|
|
285
286
|
import { loadVitestConfig } from 'nuxt-spec/config'
|
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.1.
|
|
40
|
+
'nuxt-spec': '0.1.18',
|
|
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)
|
|
@@ -107,7 +107,7 @@ export async function specSetup(autoRun = false) {
|
|
|
107
107
|
if (pathExists('.npmrc')) {
|
|
108
108
|
await updateTextFile('.npmrc', ['shamefully-hoist=true'], isAutoRun, 'This will adjust \'.npmrc\' file in your project. Continue?')
|
|
109
109
|
} else {
|
|
110
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.1.
|
|
110
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.1.18/.npmrc',
|
|
111
111
|
'.npmrc', isAutoRun, 'This will add \'.npmrc\' 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.1.
|
|
120
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.1.18/config/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,19 +155,19 @@ 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.1.
|
|
158
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.1.18/test/e2e/nuxt-e2e.test.ts',
|
|
159
159
|
'test/e2e/nuxt-e2e.test.ts', true)
|
|
160
160
|
} catch (error) {
|
|
161
161
|
console.error('Error setting up \'nuxt-e2e.test.ts\':\n', error.message)
|
|
162
162
|
}
|
|
163
163
|
try {
|
|
164
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.1.
|
|
164
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.1.18/test/nuxt/nuxt-unit.test.ts',
|
|
165
165
|
'test/nuxt/nuxt-unit.test.ts', true)
|
|
166
166
|
} catch (error) {
|
|
167
167
|
console.error('Error setting up \'nuxt-unit.test.ts\':\n', error.message)
|
|
168
168
|
}
|
|
169
169
|
try {
|
|
170
|
-
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.1.
|
|
170
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.1.18/test/unit/vitest.test.ts',
|
|
171
171
|
'test/unit/vitest.test.ts', true)
|
|
172
172
|
} catch (error) {
|
|
173
173
|
console.error('Error setting up \'vitest.test.ts\':\n', error.message)
|
package/config/index.mjs
CHANGED
|
@@ -13,11 +13,11 @@ export async function loadVitestConfig(userVitestConfig, projects = true) {
|
|
|
13
13
|
|
|
14
14
|
if (projects === true) {
|
|
15
15
|
baseConfig.test.projects = [
|
|
16
|
-
// default fallback to catch tests in /test folder
|
|
16
|
+
// default fallback to catch tests directly in /test folder
|
|
17
17
|
{
|
|
18
18
|
test: {
|
|
19
19
|
name: 'default',
|
|
20
|
-
include: ['test
|
|
20
|
+
include: ['{test,tests}/**/*.{test,spec}.ts', '!test/{nuxt,e2e,unit}/**'],
|
|
21
21
|
environment: 'node',
|
|
22
22
|
},
|
|
23
23
|
},
|
|
@@ -25,7 +25,7 @@ export async function loadVitestConfig(userVitestConfig, projects = true) {
|
|
|
25
25
|
{
|
|
26
26
|
test: {
|
|
27
27
|
name: 'node',
|
|
28
|
-
include: ['test/{e2e,unit}
|
|
28
|
+
include: ['test/{e2e,unit}/**/*.{test,spec}.ts'],
|
|
29
29
|
environment: 'node',
|
|
30
30
|
},
|
|
31
31
|
},
|
|
@@ -33,7 +33,7 @@ export async function loadVitestConfig(userVitestConfig, projects = true) {
|
|
|
33
33
|
await defineVitestProject({
|
|
34
34
|
test: {
|
|
35
35
|
name: 'nuxt',
|
|
36
|
-
include: ['test/nuxt
|
|
36
|
+
include: ['test/nuxt/**/*.{test,spec}.ts'],
|
|
37
37
|
environment: 'nuxt',
|
|
38
38
|
},
|
|
39
39
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-spec",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Test-pack layer for Nuxt Applications",
|
|
5
5
|
"repository": "github:AloisSeckar/nuxt-spec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
"public"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@nuxt/eslint": "1.
|
|
28
|
-
"@nuxt/test-utils": "
|
|
29
|
-
"@vitest/browser": "4.0.
|
|
27
|
+
"@nuxt/eslint": "1.14.0",
|
|
28
|
+
"@nuxt/test-utils": "4.0.0",
|
|
29
|
+
"@vitest/browser": "4.0.18",
|
|
30
30
|
"@vue/test-utils": "2.4.6",
|
|
31
31
|
"elrh-cosca": "0.3.5",
|
|
32
|
-
"happy-dom": "20.
|
|
33
|
-
"nuxt": "4.
|
|
34
|
-
"playwright-core": "1.
|
|
32
|
+
"happy-dom": "20.5.1",
|
|
33
|
+
"nuxt": "4.3.1",
|
|
34
|
+
"playwright-core": "1.58.2",
|
|
35
35
|
"typescript": "5.9.3",
|
|
36
|
-
"vitest": "4.0.
|
|
37
|
-
"vue": "3.5.
|
|
38
|
-
"vue-router": "
|
|
36
|
+
"vitest": "4.0.18",
|
|
37
|
+
"vue": "3.5.27",
|
|
38
|
+
"vue-router": "5.0.2"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"analyze": "nuxt analyze",
|