nuxt-spec 0.2.1 → 0.2.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- MIT License
1
+ # MIT License
2
2
 
3
- Copyright (c) 2023 Alois Sečkár
3
+ Copyright (c) 2023-present Alois Sečkár
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![Nuxt Spec](https://github.com/AloisSeckar/nuxt-spec/blob/main/public/nuxt-spec.png)
4
4
 
5
- **Nuxt Spec** (aka `nuxt-spec`) is a base layer for [Nuxt](https://nuxt.com/) applications incorporating together a couple of testing libraries and packages and providing some utility functions. I created this project in early 2025 because I was unable to find a convenient "one-dependency" way to start testing my Nuxt apps and I didn't want to repeat the same steps and maintain the same set of dependencies over and over.
5
+ **Nuxt Spec** (aka `nuxt-spec`) is a base layer for [Nuxt](https://nuxt.com/) applications incorporating together a couple of testing libraries and packages and providing some utility functions. I created this project in early 2025 because I was unable to find a convenient "one-dependency" way to start testing my Nuxt apps and I didn't want to repeat the same steps and maintain the same set of dependencies over and over.
6
6
 
7
7
  While Nuxt itself does have a [dedicated module for testing](https://nuxt.com/docs/getting-started/testing), to remain as versatile as possible, it has to be combined with other packages (which can be different based on your choice). I am trying to overcome this by defining "The Way". This is both the strength and the weakness of this project. You were warned.
8
8
 
@@ -13,6 +13,7 @@ The most important client of `nuxt-spec` is my [Nuxt Ignis](https://github.com/A
13
13
  Aside from being "forked" and used as you see fit, `nuxt-spec` is also available as an [NPM package](https://www.npmjs.com/package/nuxt-spec) that can be referenced as a single-import with all the features incoming.
14
14
 
15
15
  The `nuxt-spec` package comes with a built-in CLI tool that can help you:
16
+
16
17
  - setup the dependency in your project
17
18
  - scaffold the default `vitest.config.ts` (see [configuration](#configuration) section)
18
19
  - add a few test-related script shorthands into your `package.json` (see [running tests](#running-tests) section)
@@ -21,7 +22,7 @@ The `nuxt-spec` package comes with a built-in CLI tool that can help you:
21
22
  To use it, just run the CLI script in your terminal:
22
23
 
23
24
  | Manager | Command |
24
- |-----------------|---------|
25
+ | ----------------- | --------- |
25
26
  | npm | `npx nuxt-spec setup` |
26
27
  | yarn | `yarn dlx nuxt-spec setup` |
27
28
  | pnpm | `pnpx nuxt-spec setup` |
@@ -34,27 +35,27 @@ First, the CLI tool will ask you whether you want to do the setup automatically.
34
35
 
35
36
  If you don't want to use the CLI tool, or you want to understand its flow better, here are the detailed steps:
36
37
 
37
- 1) Add following dependency into your `package.json`:
38
+ **1)** - Add following dependency into your `package.json`:
38
39
 
39
- ```
40
- "nuxt-spec": "0.2.1"
40
+ ```json
41
+ "nuxt-spec": "0.2.2"
41
42
  ```
42
43
 
43
- 2) Add following section into your `nuxt.config.ts`:
44
+ **2** - Add following section into your `nuxt.config.ts`:
44
45
 
45
- ```
46
+ ```ts
46
47
  extends: [
47
48
  'nuxt-spec'
48
49
  ]
49
50
  ```
50
51
 
51
- 3) Add `pnpm-workspace.yaml` file with following content (if you don't have it yet):
52
+ **3)** - Add `pnpm-workspace.yaml` file with following content (if you don't have it yet):
52
53
 
53
- ```
54
+ ```yaml
54
55
  shamefullyHoist: true
55
56
  ```
56
57
 
57
- 4) Add `vitest.config.ts` file with following content (if you don't have it yet):
58
+ 1) Add `vitest.config.ts` file with following content (if you don't have it yet):
58
59
 
59
60
  ```ts
60
61
  import { loadVitestConfig } from 'nuxt-spec/config'
@@ -64,9 +65,9 @@ export default loadVitestConfig({
64
65
  })
65
66
  ```
66
67
 
67
- 5) (Optional) Add following scripts into your `package.json`:
68
+ **4)** - (Optional) Add following scripts into your `package.json`:
68
69
 
69
- ```
70
+ ```json
70
71
  "scripts": {
71
72
  "test": "vitest run",
72
73
  "test-u": "vitest run -u",
@@ -74,9 +75,9 @@ export default loadVitestConfig({
74
75
  }
75
76
  ```
76
77
 
77
- 6) (Optional) Setup file structures for tests as follows:
78
+ **5)** - (Optional) Setup file structures for tests as follows:
78
79
 
79
- ```
80
+ ```text
80
81
  test/
81
82
  ├── browser/
82
83
  │ └── vitest-browser.test.ts
@@ -89,35 +90,35 @@ test/
89
90
  └── vitest-unit.test.ts
90
91
  ```
91
92
 
92
- You can use sample files from the [project repository](https://github.com/AloisSeckar/nuxt-spec/tree/v0.2.1/test).
93
+ You can use sample files from the [project repository](https://github.com/AloisSeckar/nuxt-spec/tree/v0.2.2/test).
93
94
 
94
95
  ### Install and execute
95
96
 
96
97
  Whether you used the CLI tool or did the manual setup, you are ready to install and run the tests.
97
98
 
98
- 1) Install the dependencies:
99
+ **1)** - Install the dependencies:
99
100
 
100
101
  <!-- tabs:start -->
101
102
 
102
- #### **npm**
103
+ #### Install using **npm**
103
104
 
104
105
  ```bash
105
106
  npm install
106
107
  ```
107
108
 
108
- #### **yarn**
109
+ #### Install using **yarn**
109
110
 
110
111
  ```bash
111
112
  yarn install
112
113
  ```
113
114
 
114
- #### **pnpm**
115
+ #### Install using **pnpm**
115
116
 
116
117
  ```bash
117
118
  pnpm install
118
119
  ```
119
120
 
120
- #### **bun**
121
+ #### Install using **bun**
121
122
 
122
123
  ```bash
123
124
  bun install
@@ -125,29 +126,29 @@ bun install
125
126
 
126
127
  <!-- tabs:end -->
127
128
 
128
- 2) If you're prompted (for the first time when installing to a new machine), install headless browser runtimes:
129
+ **2)** - If you're prompted (for the first time when installing to a new machine), install headless browser runtimes:
129
130
 
130
131
  <!-- tabs:start -->
131
132
 
132
- #### **npm**
133
+ #### Setup runtime using **npm**
133
134
 
134
135
  ```bash
135
136
  npx playwright-core install
136
137
  ```
137
138
 
138
- #### **yarn**
139
+ #### Setup runtime using **yarn**
139
140
 
140
141
  ```bash
141
142
  yarn dlx playwright-core install
142
143
  ```
143
144
 
144
- #### **pnpm**
145
+ #### Setup runtime using **pnpm**
145
146
 
146
147
  ```bash
147
148
  pnpm exec playwright-core install
148
149
  ```
149
150
 
150
- #### **bun**
151
+ #### Setup runtime using **bun**
151
152
 
152
153
  ```bash
153
154
  bunx playwright-core install
@@ -155,29 +156,29 @@ bunx playwright-core install
155
156
 
156
157
  <!-- tabs:end -->
157
158
 
158
- 3) Start the development server of your awesome Nuxt project:
159
+ **3)** - Start the development server of your awesome Nuxt project:
159
160
 
160
161
  <!-- tabs:start -->
161
162
 
162
- #### **npm**
163
+ #### Start server using **npm**
163
164
 
164
165
  ```bash
165
166
  npm run dev
166
167
  ```
167
168
 
168
- #### **yarn**
169
+ #### Start server using **yarn**
169
170
 
170
171
  ```bash
171
172
  yarn dev
172
173
  ```
173
174
 
174
- #### **pnpm**
175
+ #### Start server using **pnpm**
175
176
 
176
177
  ```bash
177
178
  pnpm dev
178
179
  ```
179
180
 
180
- #### **bun**
181
+ #### Start server using **bun**
181
182
 
182
183
  ```bash
183
184
  bun run dev
@@ -190,6 +191,7 @@ bun run dev
190
191
  Once installed, Vitest automatically discovers all `*.test.ts` and `*.spec.ts` files in project and becomes capable of running them.
191
192
 
192
193
  You can use those three optional commands `package.json` file in `"scripts"` section in order to run tests easily:
194
+
193
195
  - `test: vitest run` - runs once and ends
194
196
  - `test-u: vitest run -u` - runs once and updates snapshots
195
197
  - `test-i: vitest` - runs and waits in HMR mode for test file changes
@@ -198,7 +200,7 @@ Then you can call in terminal in root of your project:
198
200
 
199
201
  <!-- tabs:start -->
200
202
 
201
- #### **npm**
203
+ #### Testing using **npm**
202
204
 
203
205
  ```bash
204
206
  npm run test # runs once and ends
@@ -206,7 +208,7 @@ npm run test-u # runs once and updates snapshots
206
208
  npm run test-i # runs and waits in HMR mode
207
209
  ```
208
210
 
209
- #### **yarn**
211
+ #### Tsting using **yarn**
210
212
 
211
213
  ```bash
212
214
  yarn test # runs once and ends
@@ -214,7 +216,7 @@ yarn test-u # runs once and updates snapshots
214
216
  yarn test-i # runs and waits in HMR mode
215
217
  ```
216
218
 
217
- #### **pnpm**
219
+ #### Testing using **pnpm**
218
220
 
219
221
  ```bash
220
222
  pnpm test # runs once and ends
@@ -222,7 +224,7 @@ pnpm test-u # runs once and updates snapshots
222
224
  pnpm test-i # runs and waits in HMR mode
223
225
  ```
224
226
 
225
- #### **bun**
227
+ #### Testing using **bun**
226
228
 
227
229
  ```bash
228
230
  bun run test # runs once and ends
@@ -237,6 +239,7 @@ Or you can use the `vitest` command directly with all its parameters. See [Vites
237
239
  ## Overview
238
240
 
239
241
  **Nuxt Spec** currently contains:
242
+
240
243
  - [vitest](https://www.npmjs.com/package/vitest) **v4** as the fundamental testing framework
241
244
  - [@vitest/browser](https://www.npmjs.com/package/@vitest/browser) as more advanced browser-native testing runner
242
245
  - [@vitest/ui](https://www.npmjs.com/package/@vitest/ui) as graphic UI above the Vitest test runner
@@ -246,14 +249,15 @@ Or you can use the `vitest` command directly with all its parameters. See [Vites
246
249
  - [@nuxt/test-utils](https://www.npmjs.com/package/@nuxt/test-utils) for testing Nuxt stuff
247
250
 
248
251
  Planned future development:
252
+
249
253
  - reason about (not) using Vitest browser mode (or make it optional)
250
254
  - solution for visual regression testing - (currently there is experimental custom solution)
251
255
 
252
- See [CHANGELOG.md](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.1/CHANGELOG.md) for the latest updates and features.
256
+ See [CHANGELOG.md](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.2/CHANGELOG.md) for the latest updates and features.
253
257
 
254
258
  ## Configuration
255
259
 
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.
260
+ By default, `nuxt-spec` uses Vitest configuration defined in [`/config/index.mjs`](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.2/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
261
 
258
262
  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
263
 
@@ -282,11 +286,12 @@ export default loadVitestConfig({
282
286
  ```
283
287
 
284
288
  By default, Nuxt Spec built-in configuration establishes 4 `projects` + one fallback:
285
- - `unit` - for unit tests in `test/unit/**` - env is set to `node`
286
- - `nuxt` - for Nuxt-related tests in `test/nuxt/**` - env is set to `nuxt`
287
- - `e2e` - for end-to-end tests in `test/e2e/**` - env is set to `node`
289
+
290
+ - `unit` - for unit tests in `test/unit/**` - env is set to `node`
291
+ - `nuxt` - for Nuxt-related tests in `test/nuxt/**` - env is set to `nuxt`
292
+ - `e2e` - for end-to-end tests in `test/e2e/**` - env is set to `node`
288
293
  - `browser` - for browser-mode tests in `test/browser/**` - env is set to `node` (this is effectively an alternative to `nuxt` relying on `@vitest/browser` instead of `@nuxt/test-utils`)
289
- - `default` - fallback for all other tests in `test/**` and/or `tests/**` directories - env is set to `node`
294
+ - `default` - fallback for all other tests in `test/**` and/or `tests/**` directories - env is set to `node`
290
295
 
291
296
  Vitest will then expect at least one test defined in either of those directories. Any parts of the `test.projects` config may be altered and user-defined values will be logically merged with the defaults. Also you may add new custom projects' definitions to fit your needs. If your project uses significantly different configuration (i.e. your tests reside in completely different path), you can pass `false` as a second parameter to `loadVitestConfig()` function to exclude default `test.projects` values from being injected completely:
292
297
 
@@ -357,7 +362,7 @@ const html: string = await getAPIResultHtml('/', '#api-fetch', '/your-api', '#ap
357
362
  const html: string = await getAPIResultHtml(page, '#api-fetch', '/your-api', '#api-result')
358
363
  ```
359
364
 
360
- For detailed description, see [utils.d.ts](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.1/utils/index.d.ts).
365
+ For detailed description, see [utils.d.ts](https://github.com/AloisSeckar/nuxt-spec/blob/v0.2.2/utils/index.d.ts).
361
366
 
362
367
  ## Contact
363
368
 
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.1',
40
+ 'nuxt-spec': '0.2.2',
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('pnpm-workspace.yaml')) {
108
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.1/config/templates/pnpm-workspace.yaml.template',
110
+ await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.2/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.1/config/templates/vitest.config.ts.template',
120
+ await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.2/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.1/test/browser/vitest-browser.test.ts',
158
+ await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.2/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.1/test/e2e/nuxt-e2e.test.ts',
164
+ await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.2/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.1/test/e2e/nuxt-visual.test.ts',
170
+ await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.2/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.1/test/nuxt/nuxt-unit.test.ts',
176
+ await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.2/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.1/test/unit/vitest-unit.test.ts',
182
+ await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v0.2.2/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/nuxt.config.ts CHANGED
@@ -9,7 +9,7 @@ export default defineNuxtConfig({
9
9
  dirs: [{ path: '~/components', ignore: ['index.ts'] }],
10
10
  },
11
11
 
12
- compatibilityDate: '2026-03-15',
12
+ compatibilityDate: '2026-05-01',
13
13
 
14
14
  eslint: {
15
15
  config: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-spec",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Test-pack layer for Nuxt Applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -39,23 +39,23 @@
39
39
  ],
40
40
  "dependencies": {
41
41
  "@nuxt/eslint": "1.15.2",
42
- "@nuxt/test-utils": "4.0.0",
43
- "@vitejs/plugin-vue": "6.0.5",
44
- "@vitest/browser": "4.1.0",
45
- "@vitest/browser-playwright": "4.1.0",
46
- "@vitest/ui": "4.1.0",
47
- "@vue/test-utils": "2.4.6",
42
+ "@nuxt/test-utils": "4.0.2",
43
+ "@vitejs/plugin-vue": "6.0.6",
44
+ "@vitest/browser": "4.1.5",
45
+ "@vitest/browser-playwright": "4.1.5",
46
+ "@vitest/ui": "4.1.5",
47
+ "@vue/test-utils": "2.4.8",
48
48
  "elrh-cosca": "0.3.5",
49
49
  "fast-png": "8.0.0",
50
- "happy-dom": "20.8.4",
50
+ "happy-dom": "20.9.0",
51
51
  "nuxt": "4.4.2",
52
52
  "pixelmatch": "7.1.0",
53
- "playwright-core": "1.58.2",
54
- "typescript": "5.9.3",
55
- "vitest": "4.1.0",
53
+ "playwright-core": "1.59.1",
54
+ "typescript": "6.0.3",
55
+ "vitest": "4.1.5",
56
56
  "vitest-browser-vue": "2.1.0",
57
- "vue": "3.5.30",
58
- "vue-router": "5.0.3"
57
+ "vue": "3.5.33",
58
+ "vue-router": "5.0.6"
59
59
  },
60
60
  "scripts": {
61
61
  "analyze": "nuxt analyze",