nuxt-spec 0.0.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/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,9 @@
1
+ {
2
+ // enable auto-linting
3
+ "editor.codeActionsOnSave": {
4
+ "source.fixAll": "explicit",
5
+ "source.fixAll.eslint": "explicit"
6
+ },
7
+ // ESlint flat config
8
+ "eslint.useFlatConfig": true
9
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 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 ADDED
@@ -0,0 +1,51 @@
1
+ # Nuxt Spec
2
+
3
+ ![Nuxt Spec](https://github.com/AloisSeckar/nuxt-spec/blob/main/public/nuxt-spec.png)
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.
6
+
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
+
9
+ The most important client of `nuxt-spec` is my [Nuxt Ignis](https://github.com/AloisSeckar/nuxt-ignis) template starter that adds up even more ready-to-use cool stuff for your future awesome Nuxt websites.
10
+
11
+
12
+ ## How to use
13
+
14
+ Aside from being "forked" and used as you seem 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.
15
+
16
+ 1) Add following dependency into your `package.json`:
17
+ ```
18
+ "nuxt-spec": "0.0.1"
19
+ ```
20
+
21
+ 2) Add following section into your `nuxt.config.ts`:
22
+ ```
23
+ extends: [
24
+ 'nuxt-spec'
25
+ ]
26
+ ```
27
+
28
+ 3) Add `.npmrc` file with following content (if you don't have it yet):
29
+ ```
30
+ shamefully-hoist=true
31
+ strict-peer-dependencies=false
32
+ ```
33
+
34
+ You are just `npm install` and `npm run dev` away from testing your Nuxt projects!
35
+
36
+
37
+ ## Overview
38
+
39
+ **Nuxt T(est)** currently contains:
40
+ - [vitest](https://www.npmjs.com/package/vitest) as the fundamental testing framework
41
+ - [happy-dom](https://www.npmjs.com/package/happy-dom) as the headless browser runtime
42
+ - [@vue/test-utils](https://www.npmjs.com/package/@vue/test-utils) for testing Vue stuff
43
+ - [@nuxt/test-utils](https://www.npmjs.com/package/@nuxt/test-utils) for testing Nuxt stuff
44
+
45
+ Planned future content:
46
+ - [backstopjs](https://www.npmjs.com/package/backstopjs) as the solution for visual testing
47
+
48
+
49
+ ## Contact
50
+
51
+ Use GitHub issues to report bugs or suggest improvements. I will be more than happy to address them.
package/app.vue ADDED
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <div>
3
+ <h1>Nuxt T(est)</h1>
4
+ <div>
5
+ Test-pack layer for <a href="https://nuxt.com/">Nuxt</a> Applications
6
+ </div>
7
+ </div>
8
+ </template>
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <div>
3
+ {{ text }}
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ defineProps({ text: String })
9
+ </script>
@@ -0,0 +1,40 @@
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
+ // files to be processed (JS/TS + Vue components)
9
+ { files: ['**/*.js', '**/*.ts', '**/*.vue'] },
10
+
11
+ // `rules` section can follow, where you can change default eslint behaviour if needed
12
+ // you can adjust or even turn off some rules if you cannot or don't want to satisfy them
13
+ {
14
+ rules: {
15
+ // the default for this rule is "1", but I find it too restrictive
16
+ // https://eslint.vuejs.org/rules/max-attributes-per-line.html
17
+ 'vue/max-attributes-per-line': ['error', {
18
+ singleline: {
19
+ max: 4,
20
+ },
21
+ multiline: {
22
+ max: 3,
23
+ },
24
+ }],
25
+ // the default rule forces newline after "else"
26
+ // I prefer using "} else {" on single row
27
+ 'vue/html-closing-bracket-newline': [
28
+ 'error',
29
+ {
30
+ multiline: 'never',
31
+ selfClosingTag: {
32
+ multiline: 'never',
33
+ },
34
+ },
35
+ ],
36
+ '@stylistic/brace-style': 'off',
37
+ },
38
+ },
39
+
40
+ ])
package/nuxt.config.ts ADDED
@@ -0,0 +1,14 @@
1
+ export default defineNuxtConfig({
2
+ modules: [
3
+ '@nuxt/eslint',
4
+ '@nuxt/test-utils/module',
5
+ ],
6
+
7
+ compatibilityDate: '2025-01-18',
8
+
9
+ eslint: {
10
+ config: {
11
+ stylistic: true,
12
+ },
13
+ },
14
+ })
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "nuxt-spec",
3
+ "version": "0.0.1",
4
+ "description": "Test-pack layer for Nuxt Applications",
5
+ "repository": "github:AloisSeckar/nuxt-spec",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./nuxt.config.ts",
9
+ "scripts": {
10
+ "analyze": "nuxt analyze",
11
+ "eslint": "eslint .",
12
+ "build": "nuxt build",
13
+ "dev": "nuxt dev",
14
+ "generate": "nuxt generate",
15
+ "preview": "nuxt preview",
16
+ "start": "nuxt start",
17
+ "test": "vitest run"
18
+ },
19
+ "dependencies": {
20
+ "@nuxt/test-utils": "3.15.4",
21
+ "@vue/test-utils": "2.4.6",
22
+ "happy-dom": "16.6.0",
23
+ "vitest": "3.0.2"
24
+ },
25
+ "devDependencies": {
26
+ "@nuxt/eslint": "0.7.5",
27
+ "nuxt": "3.15.2",
28
+ "typescript": "latest"
29
+ },
30
+ "packageManager": "pnpm@9.15.4"
31
+ }
Binary file
Binary file
@@ -0,0 +1,15 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+
4
+ import NuxtTestComponent from '../components/NuxtTestComponent.vue'
5
+
6
+ describe('NuxtTestComponent', () => {
7
+ it('component renders text properly', () => {
8
+ const wrapper = mount(NuxtTestComponent, {
9
+ propsData: {
10
+ text: 'nuxt-spec',
11
+ },
12
+ })
13
+ expect(wrapper.text()).toContain('nuxt-spec')
14
+ })
15
+ })
@@ -0,0 +1,5 @@
1
+ import { expect, test } from 'vitest'
2
+
3
+ test('vitest should run', () => {
4
+ expect(1).toBe(1)
5
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ // https://nuxt.com/docs/guide/directory-structure/tsconfig
2
+ {
3
+ "extends": "./.nuxt/tsconfig.json",
4
+ "compilerOptions": {
5
+ "noUncheckedIndexedAccess": true
6
+ }
7
+ }
@@ -0,0 +1,5 @@
1
+ // Element.checkVisibility() is not available in Vitest
2
+ global.Element.prototype.checkVisibility = function () {
3
+ // in tests we allways just assume the element is visible
4
+ return true
5
+ }
@@ -0,0 +1,8 @@
1
+ import { defineVitestConfig } from '@nuxt/test-utils/config'
2
+
3
+ export default defineVitestConfig({
4
+ test: {
5
+ environment: 'nuxt',
6
+ setupFiles: ['./utils/vitest-utils.ts'],
7
+ },
8
+ })