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.
Files changed (39) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +13 -13
  3. package/app/app.vue +10 -10
  4. package/app/components/NuxtSpecApiTestComponent.vue +24 -24
  5. package/app/components/NuxtSpecTestComponent.vue +9 -9
  6. package/app/components/index.d.ts +7 -7
  7. package/app/components/index.ts +2 -2
  8. package/app/utils/vitest-utils.ts +5 -5
  9. package/bin/_internal/prepublish-check.js +16 -16
  10. package/bin/cli.js +44 -44
  11. package/bin/helpers/commands.js +82 -82
  12. package/bin/setup.js +366 -287
  13. package/bin/update.js +94 -94
  14. package/config/index.d.ts +36 -33
  15. package/config/index.mjs +140 -132
  16. package/config/report/report-entry.html +6 -0
  17. package/config/report/report-head.html +34 -0
  18. package/{utils/screenshot/report-entry.html → config/report/report-screenshot.html} +8 -8
  19. package/config/report/report-tail.html +4 -0
  20. package/config/templates/pnpm-workspace.yaml.template +19 -19
  21. package/config/templates/vitest.config.ts.template +5 -5
  22. package/config/utils/merge.mjs +43 -43
  23. package/config/utils/options.d.mts +59 -0
  24. package/config/utils/options.mjs +116 -0
  25. package/config/utils/reporter.mjs +409 -0
  26. package/config/utils/warnings.mjs +38 -33
  27. package/modules/spec-options.ts +23 -0
  28. package/nuxt.config.ts +20 -24
  29. package/package.json +33 -31
  30. package/utils/e2e.ts +131 -131
  31. package/utils/helpers/check-params.ts +44 -41
  32. package/utils/helpers/location-hint.ts +30 -30
  33. package/utils/helpers/screenshot-utils.ts +27 -0
  34. package/utils/index.ts +12 -12
  35. package/utils/playwright.ts +28 -20
  36. package/utils/screenshot.ts +201 -172
  37. package/utils/screenshot/report-head.html +0 -24
  38. package/utils/screenshot/report-tail.html +0 -4
  39. package/utils/screenshot/report-utils.ts +0 -236
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- # MIT License
2
-
3
- Copyright (c) 2025-present Alois Sečkár
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ # MIT License
2
+
3
+ Copyright (c) 2025-present Alois Sečkár
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # Nuxt Spec
2
-
3
- ![Nuxt Spec](https://github.com/AloisSeckar/nuxt-spec/blob/main/public/nuxt-spec.png)
4
-
5
- A _"testing done right"_ Nuxt base layer.
6
-
7
- ## How to use
8
-
9
- See [ONLINE DOCS](https://nuxt-spec.netlify.app) for all the necessary information.
10
-
11
- See [CHANGELOG](https://nuxt-spec.netlify.app/3-1-changelog.html) for the full list of changes.
12
-
13
- See [CONTRIBUTING](https://nuxt-spec.netlify.app/4-1-contributing.html) if you want to help.
1
+ # Nuxt Spec
2
+
3
+ ![Nuxt Spec](https://github.com/AloisSeckar/nuxt-spec/blob/main/public/nuxt-spec.png)
4
+
5
+ A _"testing done right"_ Nuxt base layer.
6
+
7
+ ## How to use
8
+
9
+ See [ONLINE DOCS](https://nuxt-spec.netlify.app) for all the necessary information.
10
+
11
+ See [CHANGELOG](https://nuxt-spec.netlify.app/3-1-changelog.html) for the full list of changes.
12
+
13
+ See [CONTRIBUTING](https://nuxt-spec.netlify.app/4-1-contributing.html) if you want to help.
package/app/app.vue CHANGED
@@ -1,10 +1,10 @@
1
- <template>
2
- <div>
3
- <NuxtWelcome />
4
- <div>
5
- Test-pack layer for <a href="https://nuxt.com/">Nuxt</a> applications
6
- </div>
7
- <NuxtSpecTestComponent id="test" text="Test Component" />
8
- <NuxtSpecApiTestComponent />
9
- </div>
10
- </template>
1
+ <template>
2
+ <div>
3
+ <NuxtWelcome />
4
+ <div>
5
+ Test-pack layer for <a href="https://nuxt.com/">Nuxt</a> applications
6
+ </div>
7
+ <NuxtSpecTestComponent id="test" text="Test Component" />
8
+ <NuxtSpecApiTestComponent />
9
+ </div>
10
+ </template>
@@ -1,24 +1,24 @@
1
- <template>
2
- <div>
3
- <h2>API Test</h2>
4
- <button id="api-fetch" @click="fetchData">
5
- Fetch Data
6
- </button>
7
- <div id="api-result">
8
- {{ data }}
9
- </div>
10
- </div>
11
- </template>
12
-
13
- <script setup lang="ts">
14
- const data = ref('')
15
- const fetchData = async () => {
16
- try {
17
- data.value = await $fetch('https://jsonplaceholder.typicode.com/posts/1')
18
- console.debug('Fetched data:', data.value)
19
- } catch (error) {
20
- data.value = 'Error fetching data'
21
- console.error('API fetch error:', error)
22
- }
23
- }
24
- </script>
1
+ <template>
2
+ <div>
3
+ <h2>API Test</h2>
4
+ <button id="api-fetch" @click="fetchData">
5
+ Fetch Data
6
+ </button>
7
+ <div id="api-result">
8
+ {{ data }}
9
+ </div>
10
+ </div>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ const data = ref('')
15
+ const fetchData = async () => {
16
+ try {
17
+ data.value = await $fetch('https://jsonplaceholder.typicode.com/posts/1')
18
+ console.debug('Fetched data:', data.value)
19
+ } catch (error) {
20
+ data.value = 'Error fetching data'
21
+ console.error('API fetch error:', error)
22
+ }
23
+ }
24
+ </script>
@@ -1,9 +1,9 @@
1
- <template>
2
- <div data-testid="test-component" style="margin: 1rem 0; padding: 0.5rem; border: 1px solid black;">
3
- {{ text }}
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- defineProps({ text: { type: String, default: 'nuxt-spec' } })
9
- </script>
1
+ <template>
2
+ <div data-testid="test-component" style="margin: 1rem 0; padding: 0.5rem; border: 1px solid black;">
3
+ {{ text }}
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ defineProps({ text: { type: String, default: 'nuxt-spec' } })
9
+ </script>
@@ -1,7 +1,7 @@
1
- // type hint for tsconfig.nuxt-spec.json
2
- declare module '*.vue' {
3
- import type { DefineComponent } from 'vue'
4
-
5
- const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>
6
- export default component
7
- }
1
+ // type hint for tsconfig.nuxt-spec.json
2
+ declare module '*.vue' {
3
+ import type { DefineComponent } from 'vue'
4
+
5
+ const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, unknown>
6
+ export default component
7
+ }
@@ -1,2 +1,2 @@
1
- export { default as NuxtSpecTestComponent } from './NuxtSpecTestComponent.vue'
2
- export { default as NuxtSpecApiTestComponent } from './NuxtSpecApiTestComponent.vue'
1
+ export { default as NuxtSpecTestComponent } from './NuxtSpecTestComponent.vue'
2
+ export { default as NuxtSpecApiTestComponent } from './NuxtSpecApiTestComponent.vue'
@@ -1,5 +1,5 @@
1
- // Element.checkVisibility() is not available in Vitest
2
- global.Element.prototype.checkVisibility = function () {
3
- // in tests we always just assume the element is visible
4
- return true
5
- }
1
+ // Element.checkVisibility() is not available in Vitest
2
+ global.Element.prototype.checkVisibility = function () {
3
+ // in tests we always just assume the element is visible
4
+ return true
5
+ }
@@ -1,16 +1,16 @@
1
- #!/usr/bin/env node
2
-
3
- import { createInterface } from 'node:readline'
4
-
5
- const rl = createInterface({ input: process.stdin, output: process.stdout })
6
-
7
- rl.question('Are you sure the current solution was properly tested and verified? (y/n) ', (answer) => {
8
- rl.close()
9
- if (answer.trim().toLowerCase().startsWith('y')) {
10
- console.log('Proceeding with publish...')
11
- process.exit(0)
12
- } else {
13
- console.error('Publish aborted. Please run the tests and try again.')
14
- process.exit(1)
15
- }
16
- })
1
+ #!/usr/bin/env node
2
+
3
+ import { createInterface } from 'node:readline'
4
+
5
+ const rl = createInterface({ input: process.stdin, output: process.stdout })
6
+
7
+ rl.question('Are you sure the current solution was properly tested and verified? (y/n) ', (answer) => {
8
+ rl.close()
9
+ if (answer.trim().toLowerCase().startsWith('y')) {
10
+ console.log('Proceeding with publish...')
11
+ process.exit(0)
12
+ } else {
13
+ console.error('Publish aborted. Please run the tests and try again.')
14
+ process.exit(1)
15
+ }
16
+ })
package/bin/cli.js CHANGED
@@ -1,44 +1,44 @@
1
- #!/usr/bin/env node
2
-
3
- import { getCmd, resolvePackageManager } from './helpers/commands.js'
4
-
5
- /**
6
- * CLI tool to scaffold necessary adjustments in project folder.
7
- *
8
- * Allows `setup` or `update` to be passed as parameter.
9
- *
10
- * Second (optional) parameter might be a boolean to indicate auto mode
11
- * (no prompts, force = true) or manual mode (with prompts, force = false).
12
- *
13
- * Third (optional) parameter allows explicitly passing the package manager
14
- * (`npm`, `pnpm`, `yarn`, `bun` or `deno`), bypassing auto-detection.
15
- */
16
-
17
- // get parameters passed by user
18
- const args = process.argv.slice(2);
19
-
20
- // execute actions based on first param
21
- // additional params might be passed into the called functions
22
- (async () => {
23
- let status = 0
24
- try {
25
- const packageManager = resolvePackageManager(args[2])
26
- // CLI args are always strings, so 'false' must be parsed explicitly rather than treated as truthy
27
- const autoRun = args[1] === 'true'
28
- switch (args[0]) {
29
- case 'setup':
30
- await (await import('./setup.js')).specSetup(autoRun, packageManager)
31
- break
32
- case 'update':
33
- await (await import('./update.js')).specUpdate(autoRun, packageManager)
34
- break
35
- default:
36
- console.log(`Usage: \`${getCmd(packageManager)} setup [true|false] [npm|pnpm|yarn|bun|deno]\` or \`${getCmd(packageManager)} update [true|false] [npm|pnpm|yarn|bun|deno]\``)
37
- status = 1
38
- }
39
- } catch (error) {
40
- console.error('nuxt-spec CLI failed:', error.message)
41
- status = 1
42
- }
43
- process.exit(status)
44
- })()
1
+ #!/usr/bin/env node
2
+
3
+ import { getCmd, resolvePackageManager } from './helpers/commands.js'
4
+
5
+ /**
6
+ * CLI tool to scaffold necessary adjustments in project folder.
7
+ *
8
+ * Allows `setup` or `update` to be passed as parameter.
9
+ *
10
+ * Second (optional) parameter might be a boolean to indicate auto mode
11
+ * (no prompts, force = true) or manual mode (with prompts, force = false).
12
+ *
13
+ * Third (optional) parameter allows explicitly passing the package manager
14
+ * (`npm`, `pnpm`, `yarn`, `bun` or `deno`), bypassing auto-detection.
15
+ */
16
+
17
+ // get parameters passed by user
18
+ const args = process.argv.slice(2);
19
+
20
+ // execute actions based on first param
21
+ // additional params might be passed into the called functions
22
+ (async () => {
23
+ let status = 0
24
+ try {
25
+ const packageManager = resolvePackageManager(args[2])
26
+ // CLI args are always strings, so 'false' must be parsed explicitly rather than treated as truthy
27
+ const autoRun = args[1] === 'true'
28
+ switch (args[0]) {
29
+ case 'setup':
30
+ await (await import('./setup.js')).specSetup(autoRun, packageManager)
31
+ break
32
+ case 'update':
33
+ await (await import('./update.js')).specUpdate(autoRun, packageManager)
34
+ break
35
+ default:
36
+ console.log(`[Nuxt Spec] Usage: \`${getCmd(packageManager)} setup [true|false] [npm|pnpm|yarn|bun|deno]\` or \`${getCmd(packageManager)} update [true|false] [npm|pnpm|yarn|bun|deno]\``)
37
+ status = 1
38
+ }
39
+ } catch (error) {
40
+ console.error('[Nuxt Spec] CLI failed:', error.message)
41
+ status = 1
42
+ }
43
+ process.exit(status)
44
+ })()
@@ -1,82 +1,82 @@
1
- import { getPackageManager } from 'elrh-cosca'
2
-
3
- export const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'pnpm', 'yarn', 'bun', 'deno']
4
-
5
- // get the package manager name for usage in commands
6
- // explicit override takes precedence over auto-detection
7
- export function resolvePackageManager(override) {
8
- if (override) {
9
- if (!SUPPORTED_PACKAGE_MANAGERS.includes(override)) {
10
- throw new Error(`Unsupported package manager '${override}'. Use one of: ${SUPPORTED_PACKAGE_MANAGERS.join(', ')}`)
11
- }
12
- return override
13
- }
14
- return getPackageManager()
15
- }
16
-
17
- // use nuxt-spec CLI tool
18
- export function getCmd(packageManager) {
19
- const command = 'nuxt-spec'
20
- switch (packageManager) {
21
- case 'pnpm':
22
- return `pnpx ${command}`
23
- case 'yarn':
24
- return `yarn dlx ${command}`
25
- case 'bun':
26
- return `bunx ${command}`
27
- case 'deno':
28
- return `deno run -A npm:${command}`
29
- default:
30
- return `npx ${command}`
31
- }
32
- }
33
-
34
- // update nuxt-spec
35
- export function getUpdateCmd(packageManager, target) {
36
- switch (packageManager) {
37
- case 'pnpm':
38
- return `pnpm update ${target}`
39
- case 'yarn':
40
- return `yarn up ${target}`
41
- case 'bun':
42
- return `bun update ${target}`
43
- case 'deno':
44
- return `deno add npm:${target}`
45
- default:
46
- return `npm install ${target}`
47
- }
48
- }
49
-
50
- // generate Nuxt types and auto-imports
51
- export function getPrepareCmd(packageManager) {
52
- const command = 'nuxt prepare'
53
- switch (packageManager) {
54
- case 'pnpm':
55
- return `pnpm exec ${command}`
56
- case 'yarn':
57
- return `yarn ${command}`
58
- case 'bun':
59
- return `bunx ${command}`
60
- case 'deno':
61
- return `deno run -A npm:${command}`
62
- default:
63
- return `npx ${command}`
64
- }
65
- }
66
-
67
- // install/update playwright
68
- export function getPlaywrightInstallCmd(packageManager) {
69
- const command = 'playwright install'
70
- switch (packageManager) {
71
- case 'pnpm':
72
- return `pnpm exec ${command}`
73
- case 'yarn':
74
- return `yarn ${command}`
75
- case 'bun':
76
- return `bunx ${command}`
77
- case 'deno':
78
- return `deno run -A npm:${command}`
79
- default:
80
- return `npx ${command}`
81
- }
82
- }
1
+ import { getPackageManager } from 'elrh-cosca'
2
+
3
+ export const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'pnpm', 'yarn', 'bun', 'deno']
4
+
5
+ // get the package manager name for usage in commands
6
+ // explicit override takes precedence over auto-detection
7
+ export function resolvePackageManager(override) {
8
+ if (override) {
9
+ if (!SUPPORTED_PACKAGE_MANAGERS.includes(override)) {
10
+ throw new Error(`Unsupported package manager '${override}'. Use one of: ${SUPPORTED_PACKAGE_MANAGERS.join(', ')}`)
11
+ }
12
+ return override
13
+ }
14
+ return getPackageManager()
15
+ }
16
+
17
+ // use nuxt-spec CLI tool
18
+ export function getCmd(packageManager) {
19
+ const command = 'nuxt-spec'
20
+ switch (packageManager) {
21
+ case 'pnpm':
22
+ return `pnpx ${command}`
23
+ case 'yarn':
24
+ return `yarn dlx ${command}`
25
+ case 'bun':
26
+ return `bunx ${command}`
27
+ case 'deno':
28
+ return `deno run -A npm:${command}`
29
+ default:
30
+ return `npx ${command}`
31
+ }
32
+ }
33
+
34
+ // update nuxt-spec
35
+ export function getUpdateCmd(packageManager, target) {
36
+ switch (packageManager) {
37
+ case 'pnpm':
38
+ return `pnpm update ${target}`
39
+ case 'yarn':
40
+ return `yarn up ${target}`
41
+ case 'bun':
42
+ return `bun update ${target}`
43
+ case 'deno':
44
+ return `deno add npm:${target}`
45
+ default:
46
+ return `npm install ${target}`
47
+ }
48
+ }
49
+
50
+ // generate Nuxt types and auto-imports
51
+ export function getPrepareCmd(packageManager) {
52
+ const command = 'nuxt prepare'
53
+ switch (packageManager) {
54
+ case 'pnpm':
55
+ return `pnpm exec ${command}`
56
+ case 'yarn':
57
+ return `yarn ${command}`
58
+ case 'bun':
59
+ return `bunx ${command}`
60
+ case 'deno':
61
+ return `deno run -A npm:${command}`
62
+ default:
63
+ return `npx ${command}`
64
+ }
65
+ }
66
+
67
+ // install/update playwright
68
+ export function getPlaywrightInstallCmd(packageManager) {
69
+ const command = 'playwright install'
70
+ switch (packageManager) {
71
+ case 'pnpm':
72
+ return `pnpm exec ${command}`
73
+ case 'yarn':
74
+ return `yarn ${command}`
75
+ case 'bun':
76
+ return `bunx ${command}`
77
+ case 'deno':
78
+ return `deno run -A npm:${command}`
79
+ default:
80
+ return `npx ${command}`
81
+ }
82
+ }