nuxt-spec 0.1.1 → 0.1.3
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 +3 -3
- package/bin/spec-setup.js +1 -1
- package/bin/utils/create-file.js +1 -1
- package/config/index.mjs +6 -0
- package/config/vitest.config.ts.template +5 -0
- package/package.json +13 -1
- package/.gitattributes +0 -2
- package/.vscode/settings.json +0 -9
- package/CHANGELOG.md +0 -21
- package/eslint.config.mjs +0 -37
- package/test/e2e/nuxt-e2e.test.ts +0 -21
- package/test/nuxt/nuxt-unit.test.ts +0 -28
- package/test/unit/vitest.test.ts +0 -5
- package/tsconfig.json +0 -7
- package/vitest.config.ts +0 -8
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Aside from being "forked" and used as you seem fit, `nuxt-spec` is also availabl
|
|
|
14
14
|
|
|
15
15
|
1) Add following dependency into your `package.json`:
|
|
16
16
|
```
|
|
17
|
-
"nuxt-spec": "0.1.
|
|
17
|
+
"nuxt-spec": "0.1.3"
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
2) Add following section into your `nuxt.config.ts`:
|
|
@@ -43,7 +43,7 @@ The `nuxt-spec` package comes with a CLI tool that can help you:
|
|
|
43
43
|
To use it, just run the following command in your terminal after you installed `nuxt-spec` package (files must be available in your `node_modules` folder):
|
|
44
44
|
|
|
45
45
|
```bash
|
|
46
|
-
npx
|
|
46
|
+
npx spec-setup
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
You will be prompted for each action which allows you to choose only one action to run and skip the other.
|
|
@@ -84,7 +84,7 @@ By default, `nuxt-spec` uses Vitest configuration defined in [`/utils/vitest-con
|
|
|
84
84
|
To add/override your custom config, you can create a file named `vitest.config.ts` in the root of your project with the following content:
|
|
85
85
|
|
|
86
86
|
```ts
|
|
87
|
-
import { loadVitestConfig } from '
|
|
87
|
+
import { loadVitestConfig } from 'nuxt-spec'
|
|
88
88
|
|
|
89
89
|
export default loadVitestConfig({
|
|
90
90
|
// your custom config here
|
package/bin/spec-setup.js
CHANGED
|
@@ -9,7 +9,7 @@ import { updatePackageJsonScripts } from './utils/modify-scripts.js'
|
|
|
9
9
|
|
|
10
10
|
async function main() {
|
|
11
11
|
// 1) create vitest.config.ts
|
|
12
|
-
await createFileFromTemplate('../vitest.config.ts', 'vitest.config.ts')
|
|
12
|
+
await createFileFromTemplate('../config/vitest.config.ts.template', 'vitest.config.ts')
|
|
13
13
|
|
|
14
14
|
// 2) modify scripts in package.json
|
|
15
15
|
await updatePackageJsonScripts({
|
package/bin/utils/create-file.js
CHANGED
|
@@ -12,7 +12,7 @@ export async function createFileFromTemplate(templateFile, targetFile) {
|
|
|
12
12
|
const __dirname = path.dirname(__filename)
|
|
13
13
|
|
|
14
14
|
const templatePath = path.resolve(__dirname, `../${templateFile}`)
|
|
15
|
-
const targetPath = path.resolve(process.cwd(),
|
|
15
|
+
const targetPath = path.resolve(process.cwd(), targetFile)
|
|
16
16
|
|
|
17
17
|
if (!existsSync(templatePath)) {
|
|
18
18
|
console.error(`Template file not found at ${templatePath}`)
|
package/config/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-spec",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Test-pack layer for Nuxt Applications",
|
|
5
5
|
"repository": "github:AloisSeckar/nuxt-spec",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,6 +9,18 @@
|
|
|
9
9
|
"bin": {
|
|
10
10
|
"spec-setup": "./bin/spec-setup.js"
|
|
11
11
|
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./config/index.mjs",
|
|
15
|
+
"default": "./config/index.mjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"app",
|
|
20
|
+
"bin",
|
|
21
|
+
"config",
|
|
22
|
+
"public"
|
|
23
|
+
],
|
|
12
24
|
"dependencies": {
|
|
13
25
|
"@nuxt/test-utils": "3.19.2",
|
|
14
26
|
"@vue/test-utils": "2.4.6",
|
package/.gitattributes
DELETED
package/.vscode/settings.json
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
Overview of the newest features in Nuxt Spec.
|
|
4
|
-
|
|
5
|
-
## 0.1.1
|
|
6
|
-
|
|
7
|
-
**2025-08-09**
|
|
8
|
-
|
|
9
|
-
- feat: CLI tool for scaffolding `vitest.config.ts` and test-related scripts in `package.json`
|
|
10
|
-
- docs: added `CHANGELOG.md` and fixed link to `playwright-core`
|
|
11
|
-
|
|
12
|
-
## 0.1.0
|
|
13
|
-
|
|
14
|
-
**2025-08-08**
|
|
15
|
-
|
|
16
|
-
- initial release [v0.1.0](https://github.com/AloisSeckar/nuxt-spec/releases/tag/v0.1.0)
|
|
17
|
-
- key features:
|
|
18
|
-
- Nuxt base layer for testing
|
|
19
|
-
- Nuxt v4 and Vitest v4 compatibility
|
|
20
|
-
- Integrated `vitest`, `@vitest/browser`, `happy-dom`, `playwright-core`, `@vue/test-utils`, `@nuxt/test-utils`
|
|
21
|
-
- Support for custom configuration via `loadVitestConfig` function in `vitest.config.ts`
|
package/eslint.config.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import withNuxt from './.nuxt/eslint.config.mjs'
|
|
2
|
-
|
|
3
|
-
// config is being passed as an array of separate objects
|
|
4
|
-
// as suggested here: https://github.com/nuxt/eslint/discussions/413
|
|
5
|
-
|
|
6
|
-
export default withNuxt([
|
|
7
|
-
|
|
8
|
-
// `rules` section can follow, where you can change default eslint behaviour if needed
|
|
9
|
-
// you can adjust or even turn off some rules if you cannot or don't want to satisfy them
|
|
10
|
-
{
|
|
11
|
-
rules: {
|
|
12
|
-
// the default for this rule is "1", but I find it too restrictive
|
|
13
|
-
// https://eslint.vuejs.org/rules/max-attributes-per-line.html
|
|
14
|
-
'vue/max-attributes-per-line': ['error', {
|
|
15
|
-
singleline: {
|
|
16
|
-
max: 4,
|
|
17
|
-
},
|
|
18
|
-
multiline: {
|
|
19
|
-
max: 3,
|
|
20
|
-
},
|
|
21
|
-
}],
|
|
22
|
-
// the default rule forces newline after "else"
|
|
23
|
-
// I prefer using "} else {" on single row
|
|
24
|
-
'vue/html-closing-bracket-newline': [
|
|
25
|
-
'error',
|
|
26
|
-
{
|
|
27
|
-
multiline: 'never',
|
|
28
|
-
selfClosingTag: {
|
|
29
|
-
multiline: 'never',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
'@stylistic/brace-style': 'off',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
])
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { setup, $fetch, createPage, url } from '@nuxt/test-utils/e2e'
|
|
2
|
-
import { describe, expect, test } from 'vitest'
|
|
3
|
-
|
|
4
|
-
describe('NuxtTestComponent E2E test', async () => {
|
|
5
|
-
// setup app.vue in headless browser
|
|
6
|
-
await setup()
|
|
7
|
-
|
|
8
|
-
test('component renders in browser', async () => {
|
|
9
|
-
// fetch for the rendered value
|
|
10
|
-
const html = await $fetch('/')
|
|
11
|
-
expect(html).toContain('Test Component')
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
test('with playwright', async () => {
|
|
15
|
-
// render page in headless browser
|
|
16
|
-
const page = await createPage()
|
|
17
|
-
await page.goto(url('/'), { waitUntil: 'hydration' })
|
|
18
|
-
const hasText = await page.getByText('Test Component').isVisible()
|
|
19
|
-
expect(hasText).toBeTruthy()
|
|
20
|
-
})
|
|
21
|
-
})
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from 'vitest'
|
|
2
|
-
import { mount } from '@vue/test-utils'
|
|
3
|
-
import { mountSuspended } from '@nuxt/test-utils/runtime'
|
|
4
|
-
import NuxtTestComponent from '../../app/components/NuxtTestComponent.vue'
|
|
5
|
-
|
|
6
|
-
const text = 'custom-text'
|
|
7
|
-
|
|
8
|
-
describe('NuxtTestComponent', () => {
|
|
9
|
-
test('component mounts and renders text properly', () => {
|
|
10
|
-
const wrapper = mount(NuxtTestComponent, {
|
|
11
|
-
propsData: {
|
|
12
|
-
text,
|
|
13
|
-
},
|
|
14
|
-
})
|
|
15
|
-
expect(wrapper.text()).toContain(text)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
describe('NuxtTestComponentSuspended', () => {
|
|
20
|
-
test('component mounts using mountSuspended and renders text properly', async () => {
|
|
21
|
-
const component = await mountSuspended(NuxtTestComponent, {
|
|
22
|
-
props: {
|
|
23
|
-
text,
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
expect(component.html()).toContain(text)
|
|
27
|
-
})
|
|
28
|
-
})
|
package/test/unit/vitest.test.ts
DELETED
package/tsconfig.json
DELETED
package/vitest.config.ts
DELETED