nuxt-spec 0.2.0-alpha.3 → 0.2.0-alpha.4
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 +8 -8
- package/package.json +1 -1
- package/utils/index.d.ts +8 -4
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.0-alpha.
|
|
40
|
+
"nuxt-spec": "0.2.0-alpha.4"
|
|
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.0-alpha.
|
|
92
|
+
You can use sample files from the [project repository](https://github.com/AloisSeckar/nuxt-spec/tree/v0.2.0-alpha.4/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.0-alpha.
|
|
252
|
+
See [CHANGELOG.md](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.0-alpha.4/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.0-alpha.
|
|
256
|
+
By default, `nuxt-spec` uses Vitest configuration defined in [`/config/index.mjs`](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.0-alpha.4/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
|
|
|
@@ -341,7 +341,7 @@ const html: string = await getAPIResultHtml('/', '#api-fetch', '/your-api', '#ap
|
|
|
341
341
|
const html: string = await getAPIResultHtml(page, '#api-fetch', '/your-api', '#api-result')
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
-
For detailed description, see [utils.d.ts](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.0-alpha.
|
|
344
|
+
For detailed description, see [utils.d.ts](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.0-alpha.4/utils/index.d.ts).
|
|
345
345
|
|
|
346
346
|
## Contact
|
|
347
347
|
|
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.0-alpha.
|
|
40
|
+
'nuxt-spec': '0.2.0-alpha.4',
|
|
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.2.0-alpha.
|
|
110
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.0-alpha.4/.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.2.0-alpha.
|
|
120
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.0-alpha.4/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,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.0-alpha.
|
|
158
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.0-alpha.4/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.0-alpha.
|
|
164
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.0-alpha.4/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.0-alpha.
|
|
170
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.0-alpha.4/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.0-alpha.
|
|
176
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.0-alpha.4/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.0-alpha.
|
|
182
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.0-alpha.4/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)
|
package/package.json
CHANGED
package/utils/index.d.ts
CHANGED
|
@@ -41,13 +41,17 @@ export declare function getAPIResultHtml(
|
|
|
41
41
|
* screenshot is saved as the new baseline.
|
|
42
42
|
*
|
|
43
43
|
* @param page - Playwright page instance obtained from `createPage()`
|
|
44
|
-
* @param fileName - Name of the PNG file used for baseline storage and comparison
|
|
45
|
-
* @param targetDir - Directory for baseline/current screenshots, relative to project root (defaults to `test/e2e`)
|
|
44
|
+
* @param options.fileName - Name of the PNG file used for baseline storage and comparison (defaults to route and `index.png` for `/`)
|
|
45
|
+
* @param options.targetDir - Directory for baseline/current screenshots, relative to project root (defaults to `test/e2e`)
|
|
46
|
+
* @param options.selector - CSS selector for a specific element to capture (defaults to full page)
|
|
46
47
|
* @returns `true` when the screenshot matches the baseline (or a new baseline was saved)
|
|
47
48
|
* @throws Fails the current Vitest test when a mismatch is detected
|
|
48
49
|
*/
|
|
49
50
|
export declare function compareScreenshot(
|
|
50
51
|
page: NuxtPage,
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
options?: {
|
|
53
|
+
fileName?: string
|
|
54
|
+
targetDir?: string
|
|
55
|
+
selector?: string
|
|
56
|
+
},
|
|
53
57
|
): Promise<boolean>
|