nuxt-spec 0.3.0 → 0.3.1-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/config/index.d.ts CHANGED
@@ -1,33 +1,33 @@
1
- import type { UserConfig } from 'vite'
2
- import type { TestUserConfig } from 'vitest/config'
3
-
4
- /** Typed Vite configuration object for tests */
5
- type ExtendedUserConfig = UserConfig & {
6
- test?: TestUserConfig
7
- }
8
-
9
- /**
10
- * Allows fine-grained control over default Vitest `projects`.
11
- *
12
- * By default, everything is included.
13
- * If set to `false`, `test.projects` key is not merged at all.
14
- * If set to object, specific projects can be omitted by setting respective key to `false`.
15
- */
16
- type ProjectsConfig = boolean | {
17
- default?: boolean
18
- node?: boolean
19
- nuxt?: boolean
20
- e2e?: boolean
21
- browser?: boolean
22
- }
23
-
24
- /**
25
- * Prepare Vitest configuration object - user config merged with nuxt-spec defaults
26
- * @param userVitestConfig - custom Vitest config passed from the user
27
- * @param projects - allows fine-grained control over default `test.projects` - see `ProjectsConfig` for details
28
- * @returns Promise resolving to defu-merged Vitest configuration
29
- */
30
- export declare function loadVitestConfig(
31
- userVitestConfig: ExtendedUserConfig,
32
- projects?: ProjectsConfig,
33
- ): Promise<ExtendedUserConfig>
1
+ import type { UserConfig } from 'vite'
2
+ import type { TestUserConfig } from 'vitest/config'
3
+
4
+ /** Typed Vite configuration object for tests */
5
+ type ExtendedUserConfig = UserConfig & {
6
+ test?: TestUserConfig
7
+ }
8
+
9
+ /**
10
+ * Allows fine-grained control over default Vitest `projects`.
11
+ *
12
+ * By default, everything is included.
13
+ * If set to `false`, `test.projects` key is not merged at all.
14
+ * If set to object, specific projects can be omitted by setting respective key to `false`.
15
+ */
16
+ type ProjectsConfig = boolean | {
17
+ default?: boolean
18
+ node?: boolean
19
+ nuxt?: boolean
20
+ e2e?: boolean
21
+ browser?: boolean
22
+ }
23
+
24
+ /**
25
+ * Prepare Vitest configuration object - user config merged with nuxt-spec defaults
26
+ * @param userVitestConfig - custom Vitest config passed from the user
27
+ * @param projects - allows fine-grained control over default `test.projects` - see `ProjectsConfig` for details
28
+ * @returns Promise resolving to defu-merged Vitest configuration
29
+ */
30
+ export declare function loadVitestConfig(
31
+ userVitestConfig: ExtendedUserConfig,
32
+ projects?: ProjectsConfig,
33
+ ): Promise<ExtendedUserConfig>
package/config/index.mjs CHANGED
@@ -1,114 +1,114 @@
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 { defineConfig } from 'vitest/config'
10
- import { defineVitestProject } from '@nuxt/test-utils/config'
11
- import { playwright } from '@vitest/browser-playwright'
12
- import vue from '@vitejs/plugin-vue'
13
-
14
- // absolute path so it works from nuxt-ignis package
15
- const screenshotReportSetup = fileURLToPath(new URL('../utils/screenshot.ts', import.meta.url))
16
-
17
- export async function loadVitestConfig(userVitestConfig, projects = true) {
18
- const baseConfig = {
19
- test: {
20
- // filter-out unnecessary console logs coming from Vitest
21
- // when the import is resolved, unnecessary stderr logs are also filtered-out
22
- // as a side-effect
23
- onConsoleLog,
24
- // Vitest defaults to 5 which might be unnecessarily restrictive
25
- // if the host machine can support more
26
- maxConcurrency: availableParallelism() / 2,
27
- },
28
- }
29
-
30
- // add proposed projects settings
31
- // user can control the inclusion via `projects: ProjectsConfig` config object
32
- // projects are included by default unless not explicitly disabled
33
- if (projects !== false) {
34
- baseConfig.test.projects = []
35
-
36
- // default fallback to catch tests directly in /test folder
37
- if (projects.default !== false) {
38
- baseConfig.test.projects.push({
39
- extends: true,
40
- test: {
41
- name: 'default',
42
- include: ['{test,tests}/**/*.{test,spec}.ts', '!test/{browser,e2e,nuxt,unit}/**'],
43
- environment: 'node',
44
- },
45
- })
46
- }
47
-
48
- // proposed setup for Unit tests
49
- if (projects.node !== false) {
50
- baseConfig.test.projects.push({
51
- extends: true,
52
- test: {
53
- name: 'node',
54
- include: ['test/unit/**/*.{test,spec}.ts'],
55
- environment: 'node',
56
- },
57
- })
58
- }
59
-
60
- // proposed setup for Nuxt component tests
61
- if (projects.nuxt !== false) {
62
- baseConfig.test.projects.push(
63
- await defineVitestProject({
64
- extends: true,
65
- test: {
66
- name: 'nuxt',
67
- include: ['test/nuxt/**/*.{test,spec}.ts'],
68
- environment: 'nuxt',
69
- },
70
- }),
71
- )
72
- }
73
-
74
- // proposed setup for classic E2E tests (node-based, using @nuxt/test-utils)
75
- if (projects.e2e !== false) {
76
- baseConfig.test.projects.push({
77
- extends: true,
78
- test: {
79
- name: 'e2e',
80
- include: ['test/e2e/**/*.{test,spec}.ts'],
81
- environment: 'node',
82
- // create report file for visual regression testing
83
- globalSetup: [screenshotReportSetup],
84
- },
85
- })
86
- }
87
-
88
- // proposed setup for browser component tests (with Playwright runner)
89
- if (projects.browser !== false) {
90
- baseConfig.test.projects.push({
91
- extends: true,
92
- // vue plugin is required for proper imports resolution
93
- plugins: [vue()],
94
- test: {
95
- name: 'browser',
96
- include: ['test/browser/**/*.{test,spec}.ts'],
97
- environment: 'node',
98
- // only chromium browser - add others manually if needed
99
- browser: {
100
- provider: playwright(),
101
- enabled: true,
102
- headless: true,
103
- instances: [{
104
- browser: 'chromium',
105
- viewport: { width: 1280, height: 720 },
106
- }],
107
- },
108
- },
109
- })
110
- }
111
- }
112
-
113
- return mergeConfig(userVitestConfig, defineConfig(baseConfig))
114
- }
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 { defineConfig } from 'vitest/config'
10
+ import { defineVitestProject } from '@nuxt/test-utils/config'
11
+ import { playwright } from '@vitest/browser-playwright'
12
+ import vue from '@vitejs/plugin-vue'
13
+
14
+ // absolute path so it works from nuxt-ignis package
15
+ const screenshotReportSetup = fileURLToPath(new URL('../utils/screenshot.ts', import.meta.url))
16
+
17
+ export async function loadVitestConfig(userVitestConfig, projects = true) {
18
+ const baseConfig = {
19
+ test: {
20
+ // filter-out unnecessary console logs coming from Vitest
21
+ // when the import is resolved, unnecessary stderr logs are also filtered-out
22
+ // as a side-effect
23
+ onConsoleLog,
24
+ // Vitest defaults to 5 which might be unnecessarily restrictive
25
+ // if the host machine can support more
26
+ maxConcurrency: availableParallelism() / 2,
27
+ },
28
+ }
29
+
30
+ // add proposed projects settings
31
+ // user can control the inclusion via `projects: ProjectsConfig` config object
32
+ // projects are included by default unless not explicitly disabled
33
+ if (projects !== false) {
34
+ baseConfig.test.projects = []
35
+
36
+ // default fallback to catch tests directly in /test folder
37
+ if (projects.default !== false) {
38
+ baseConfig.test.projects.push({
39
+ extends: true,
40
+ test: {
41
+ name: 'default',
42
+ include: ['{test,tests}/**/*.{test,spec}.ts', '!test/{browser,e2e,nuxt,unit}/**'],
43
+ environment: 'node',
44
+ },
45
+ })
46
+ }
47
+
48
+ // proposed setup for Unit tests
49
+ if (projects.node !== false) {
50
+ baseConfig.test.projects.push({
51
+ extends: true,
52
+ test: {
53
+ name: 'node',
54
+ include: ['test/unit/**/*.{test,spec}.ts'],
55
+ environment: 'node',
56
+ },
57
+ })
58
+ }
59
+
60
+ // proposed setup for Nuxt component tests
61
+ if (projects.nuxt !== false) {
62
+ baseConfig.test.projects.push(
63
+ await defineVitestProject({
64
+ extends: true,
65
+ test: {
66
+ name: 'nuxt',
67
+ include: ['test/nuxt/**/*.{test,spec}.ts'],
68
+ environment: 'nuxt',
69
+ },
70
+ }),
71
+ )
72
+ }
73
+
74
+ // proposed setup for classic E2E tests (node-based, using @nuxt/test-utils)
75
+ if (projects.e2e !== false) {
76
+ baseConfig.test.projects.push({
77
+ extends: true,
78
+ test: {
79
+ name: 'e2e',
80
+ include: ['test/e2e/**/*.{test,spec}.ts'],
81
+ environment: 'node',
82
+ // create report file for visual regression testing
83
+ globalSetup: [screenshotReportSetup],
84
+ },
85
+ })
86
+ }
87
+
88
+ // proposed setup for browser component tests (with Playwright runner)
89
+ if (projects.browser !== false) {
90
+ baseConfig.test.projects.push({
91
+ extends: true,
92
+ // vue plugin is required for proper imports resolution
93
+ plugins: [vue()],
94
+ test: {
95
+ name: 'browser',
96
+ include: ['test/browser/**/*.{test,spec}.ts'],
97
+ environment: 'node',
98
+ // only chromium browser - add others manually if needed
99
+ browser: {
100
+ provider: playwright(),
101
+ enabled: true,
102
+ headless: true,
103
+ instances: [{
104
+ browser: 'chromium',
105
+ viewport: { width: 1280, height: 720 },
106
+ }],
107
+ },
108
+ },
109
+ })
110
+ }
111
+ }
112
+
113
+ return mergeConfig(userVitestConfig, defineConfig(baseConfig))
114
+ }
@@ -1,4 +1,4 @@
1
- # settings for Nuxt & pnpm
2
-
3
- # https://pnpm.io/settings#shamefullyhoist
4
- shamefullyHoist: true
1
+ # settings for Nuxt & pnpm
2
+
3
+ # https://pnpm.io/settings#shamefullyhoist
4
+ shamefullyHoist: true
@@ -1,5 +1,5 @@
1
- import { loadVitestConfig } from 'nuxt-spec/config'
2
-
3
- export default loadVitestConfig({
4
- // custom config here
5
- })
1
+ import { loadVitestConfig } from 'nuxt-spec/config'
2
+
3
+ export default loadVitestConfig({
4
+ // custom config here
5
+ })
@@ -1,43 +1,43 @@
1
- // custom merger function based on defu
2
- // allows working with the "projects" array properly
3
- // user-defined config overrides are merged by "name"
4
-
5
- // for consistent and predictable results, passing "include" or "browser.instances"
6
- // will result in OVERRIDE instead of merging with nuxt-spec defaults
7
-
8
- import { createDefu } from 'defu'
9
-
10
- // in real Vitest config, "name" is nested inside another "test" object
11
- const getProjectName = project => project?.name ?? project?.test?.name
12
-
13
- export const mergeConfig = createDefu((obj, key, value) => {
14
- if (key === 'projects' && Array.isArray(obj[key]) && Array.isArray(value)) {
15
- const defaults = obj[key]
16
- const overrides = value
17
-
18
- // override default values if user-defined config specifies them
19
- obj[key] = defaults.map((defaultProject) => {
20
- const override = overrides.find(o => getProjectName(o) === getProjectName(defaultProject))
21
- return override ? mergeProject(override, defaultProject) : defaultProject
22
- })
23
-
24
- // add any user projects that don't exist in defaults
25
- for (const override of overrides) {
26
- if (!defaults.some(d => getProjectName(d) === getProjectName(override))) {
27
- obj[key].push(override)
28
- }
29
- }
30
-
31
- return true
32
- }
33
- })
34
-
35
- // Keys where user value should fully replace the default, not merge
36
- const overrideKeys = new Set(['include', 'instances'])
37
-
38
- const mergeProject = createDefu((obj, key, value) => {
39
- if (overrideKeys.has(key)) {
40
- obj[key] = value
41
- return true
42
- }
43
- })
1
+ // custom merger function based on defu
2
+ // allows working with the "projects" array properly
3
+ // user-defined config overrides are merged by "name"
4
+
5
+ // for consistent and predictable results, passing "include" or "browser.instances"
6
+ // will result in OVERRIDE instead of merging with nuxt-spec defaults
7
+
8
+ import { createDefu } from 'defu'
9
+
10
+ // in real Vitest config, "name" is nested inside another "test" object
11
+ const getProjectName = project => project?.name ?? project?.test?.name
12
+
13
+ export const mergeConfig = createDefu((obj, key, value) => {
14
+ if (key === 'projects' && Array.isArray(obj[key]) && Array.isArray(value)) {
15
+ const defaults = obj[key]
16
+ const overrides = value
17
+
18
+ // override default values if user-defined config specifies them
19
+ obj[key] = defaults.map((defaultProject) => {
20
+ const override = overrides.find(o => getProjectName(o) === getProjectName(defaultProject))
21
+ return override ? mergeProject(override, defaultProject) : defaultProject
22
+ })
23
+
24
+ // add any user projects that don't exist in defaults
25
+ for (const override of overrides) {
26
+ if (!defaults.some(d => getProjectName(d) === getProjectName(override))) {
27
+ obj[key].push(override)
28
+ }
29
+ }
30
+
31
+ return true
32
+ }
33
+ })
34
+
35
+ // Keys where user value should fully replace the default, not merge
36
+ const overrideKeys = new Set(['include', 'instances'])
37
+
38
+ const mergeProject = createDefu((obj, key, value) => {
39
+ if (overrideKeys.has(key)) {
40
+ obj[key] = value
41
+ return true
42
+ }
43
+ })
@@ -1,33 +1,33 @@
1
- const messageFilters = [
2
- // Node+Windows false positive
3
- // https://github.com/nuxt/icon/issues/140
4
- 'Use of deprecated trailing slash pattern mapping',
5
- // remove once Vue stops considering <Suspense> experimental
6
- '<Suspense> is an experimental feature',
7
- // merge defaults with user-defined filters from NUXT_SPEC_MESSAGE_FILTERS env variable
8
- ...(process.env.NUXT_SPEC_MESSAGE_FILTERS
9
- ? process.env.NUXT_SPEC_MESSAGE_FILTERS.split(',')
10
- : []),
11
- ]
12
-
13
- // 1) filter-out unnecessary stderr/stdout logs coming from Vitest
14
- // (applied as side-effect on import)
15
-
16
- const _stderrWrite = process.stderr.write.bind(process.stderr)
17
- process.stderr.write = (chunk, ...args) => {
18
- if (typeof chunk === 'string' && messageFilters.some(f => chunk.includes(f))) return true
19
- return _stderrWrite(chunk, ...args)
20
- }
21
-
22
- const _stdoutWrite = process.stdout.write.bind(process.stdout)
23
- process.stdout.write = (chunk, ...args) => {
24
- if (typeof chunk === 'string' && messageFilters.some(f => chunk.includes(f))) return true
25
- return _stdoutWrite(chunk, ...args)
26
- }
27
-
28
- // 2) filter-out unnecessary console logs coming from Vitest
29
- // (used as Vitest onConsoleLog hook)
30
-
31
- export function onConsoleLog(log) {
32
- if (messageFilters.some(f => log.includes(f))) return false
33
- }
1
+ const messageFilters = [
2
+ // Node+Windows false positive
3
+ // https://github.com/nuxt/icon/issues/140
4
+ 'Use of deprecated trailing slash pattern mapping',
5
+ // remove once Vue stops considering <Suspense> experimental
6
+ '<Suspense> is an experimental feature',
7
+ // merge defaults with user-defined filters from NUXT_SPEC_MESSAGE_FILTERS env variable
8
+ ...(process.env.NUXT_SPEC_MESSAGE_FILTERS
9
+ ? process.env.NUXT_SPEC_MESSAGE_FILTERS.split(',')
10
+ : []),
11
+ ]
12
+
13
+ // 1) filter-out unnecessary stderr/stdout logs coming from Vitest
14
+ // (applied as side-effect on import)
15
+
16
+ const _stderrWrite = process.stderr.write.bind(process.stderr)
17
+ process.stderr.write = (chunk, ...args) => {
18
+ if (typeof chunk === 'string' && messageFilters.some(f => chunk.includes(f))) return true
19
+ return _stderrWrite(chunk, ...args)
20
+ }
21
+
22
+ const _stdoutWrite = process.stdout.write.bind(process.stdout)
23
+ process.stdout.write = (chunk, ...args) => {
24
+ if (typeof chunk === 'string' && messageFilters.some(f => chunk.includes(f))) return true
25
+ return _stdoutWrite(chunk, ...args)
26
+ }
27
+
28
+ // 2) filter-out unnecessary console logs coming from Vitest
29
+ // (used as Vitest onConsoleLog hook)
30
+
31
+ export function onConsoleLog(log) {
32
+ if (messageFilters.some(f => log.includes(f))) return false
33
+ }
package/nuxt.config.ts CHANGED
@@ -1,19 +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-07-21',
13
-
14
- eslint: {
15
- config: {
16
- stylistic: true,
17
- },
18
- },
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-08-08',
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.3.0",
3
+ "version": "0.3.1-alpha.1",
4
4
  "description": "Test-pack layer for Nuxt Applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,20 +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
- "typecheck": "nuxi typecheck",
16
- "build": "nuxt build",
17
- "dev": "nuxt dev",
18
- "generate": "nuxt generate",
19
- "prepublishOnly": "node bin/prepublish-check.js",
20
- "preview": "nuxt preview",
21
- "start": "nuxt start",
22
- "test": "vitest run",
23
- "test-u": "vitest run -u",
24
- "test-i": "vitest"
25
- },
26
12
  "bin": {
27
13
  "nuxt-spec": "bin/cli.js"
28
14
  },
@@ -52,7 +38,7 @@
52
38
  "nuxt.config.ts"
53
39
  ],
54
40
  "dependencies": {
55
- "@nuxt/eslint": "~1.16.0",
41
+ "@nuxt/eslint": "~1.17.0",
56
42
  "@nuxt/test-utils": "4.1.0",
57
43
  "@vitejs/plugin-vue": "~6.0.8",
58
44
  "@vitest/browser": "4.1.10",
@@ -61,16 +47,28 @@
61
47
  "@vue/test-utils": "2.4.11",
62
48
  "elrh-cosca": "0.3.6",
63
49
  "fast-png": "~8.0.0",
64
- "happy-dom": "~20.11.0",
65
- "nuxt": "4.5.1",
50
+ "happy-dom": "~20.11.2",
51
+ "nuxt": "4.5.2",
66
52
  "pixelmatch": "~7.2.0",
67
- "playwright-core": "~1.62.0",
53
+ "playwright-core": "~1.62.1",
68
54
  "typescript": "~6.0.3",
69
55
  "vitest": "4.1.10",
70
56
  "vitest-browser-vue": "2.1.0",
71
57
  "vue": "~3.5.40",
72
58
  "vue-router": "~5.2.0",
73
- "vue-tsc": "~3.3.8"
59
+ "vue-tsc": "~3.3.9"
74
60
  },
75
- "packageManager": "pnpm@11.17.0"
76
- }
61
+ "scripts": {
62
+ "analyze": "nuxt analyze",
63
+ "eslint": "eslint .",
64
+ "typecheck": "nuxi typecheck",
65
+ "build": "nuxt build",
66
+ "dev": "nuxt dev",
67
+ "generate": "nuxt generate",
68
+ "preview": "nuxt preview",
69
+ "start": "nuxt start",
70
+ "test": "vitest run",
71
+ "test-u": "vitest run -u",
72
+ "test-i": "vitest"
73
+ }
74
+ }