Skip to content

Commit

Permalink
Merge pull request #39 from undone-labs/feat-vitest
Browse files Browse the repository at this point in the history
feat: vitest
  • Loading branch information
timelytree authored Sep 30, 2024
2 parents 1c14517 + 300586d commit 7d76a84
Show file tree
Hide file tree
Showing 14 changed files with 2,785 additions and 2,614 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# .github/workflows/auto-author-assign.yml
name: Author auto-assign
name: author-auto-assign

on:
pull_request_target:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/vitest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: vitest

on:
push:
branches:
- main
- stable
- develop
pull_request:
branches:
- main
- stable
- develop

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Installing dependencies
run: npm ci
- name: Running zero-core tests
run: npm run zero-core:test
5,241 changes: 2,640 additions & 2,601 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
"site:generate": "npm run generate -w site",
"site:serve": "npm run serve -w site",
"site:upgrade-nuxt": "npm run upgrade-nuxt -w site",
"site:test": "npm run test -w site",
"docs:dev": "npm run docs:dev -w docs",
"docs:build": "npm run docs:build -w docs",
"docs:preview": "npm run docs:preview -w docs"
"docs:preview": "npm run docs:preview -w docs",
"docs:test": "npm run docs:test -w docs",
"zero-core:test": "npm run test -w zero-core"
},
"workspaces": [
"packages/zero-core",
Expand Down
21 changes: 15 additions & 6 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,33 @@
"type": "module",
"version": "1.0.0",
"devDependencies": {
"jsdoc-to-markdown": "^8.0.3",
"json2md": "^2.0.1",
"@nuxt/test-utils": "^3.14.2",
"@pinia/testing": "^0.1.5",
"@vue/test-utils": "^2.4.6",
"happy-dom": "^15.7.4",
"node-sass": "^9.0.0",
"playwright-core": "^1.47.1",
"sass": "^1.77.8",
"sass-loader": "^16.0.0",
"vitepress": "^1.3.2",
"vitepress-jsdoc": "^1.0.4",
"vue": "^3.4.37",
"vue-docgen-api": "^4.79.2"
"vitest": "^2.1.1",
"vue": "^3.4.37"
},
"scripts": {
"docs:dev": "node generate.js && vitepress dev",
"docs:build": "vitepress build",
"docs:preview": "vitepress preview"
"docs:preview": "vitepress preview",
"docs:test": "vitest"
},
"dependencies": {
"comment-parser": "^1.4.1",
"esm-resolve": "^1.0.11",
"jsdoc-to-markdown": "^9.0.2",
"json2md": "^2.0.1",
"lru-cache": "^8.0.0",
"pug": "^3.0.3",
"recast": "^0.23.9",
"vue-inbrowser-compiler-independent-utils": "^4.71.1",
"vue-router": "^4.4.3"
}
}
11 changes: 11 additions & 0 deletions packages/docs/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineVitestConfig } from '@nuxt/test-utils/config'

export default defineVitestConfig({
test: {
environment: 'node',
coverage: {
provider: 'v8'
},
include: ['tests/component/*.{test,spec}.?(c|m)[jt]s?(x)']
}
})
3 changes: 2 additions & 1 deletion packages/site/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export default defineNuxtConfig({
modules: [
'@nuxt/eslint',
'@pinia/nuxt',
'@nuxt/content'
'@nuxt/content',
'@nuxt/test-utils/module'
],
// ============================================================ [Module] Pinia
pinia: {
Expand Down
11 changes: 10 additions & 1 deletion packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "nuxi build",
"generate": "nuxi generate",
"serve": "npx serve .output/public --ssl-cert=../../localhost_cert.pem --ssl-key=../../localhost_key.pem",
"upgrade-nuxt": "nuxi upgrade --force"
"upgrade-nuxt": "nuxi upgrade --force",
"test": "vitest"
},
"dependencies": {
"@nuxt/content": "^2.8.5",
Expand All @@ -20,5 +21,13 @@
"sass": "^1.68.0",
"typescript": "^5.2.2",
"vue3-google-login": "^2.0.33"
},
"devDependencies": {
"@nuxt/test-utils": "^3.14.2",
"@pinia/testing": "^0.1.5",
"@vue/test-utils": "^2.4.6",
"happy-dom": "^15.7.4",
"playwright-core": "^1.47.1",
"vitest": "^2.1.1"
}
}
11 changes: 11 additions & 0 deletions packages/site/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineVitestConfig } from '@nuxt/test-utils/config'

export default defineVitestConfig({
test: {
environment: 'nuxt',
coverage: {
provider: 'v8'
},
include: ['tests/component/*.{test,spec}.?(c|m)[jt]s?(x)']
}
})
7 changes: 6 additions & 1 deletion packages/zero-core/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ export default defineNuxtConfig({
'../zero-core/stores/**'
]
},
// ========================================================= [Layer] zero-core
zero: {
modules: {}
},
// =================================================================== Modules
modules: [
'nuxt-simple-sitemap', // https://github.com/harlan-zw/nuxt-simple-sitemap
'nuxt-primevue', // https://github.com/primefaces/primevue-nuxt-module
'@vueuse/nuxt' // https://vueuse.org/
'@vueuse/nuxt', // https://vueuse.org/
'@nuxt/test-utils/module' //https://nuxt.com/docs/getting-started/testing
],
// ========================================================== [Module] sitemap
sitemap: {
Expand Down
13 changes: 12 additions & 1 deletion packages/zero-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "zero-core",
"version": "1.0.0",
"description": "Supercharge your Nuxt3 setup 💪",
"scripts": {
"test": "vitest"
},
"dependencies": {
"@floating-ui/vue": "^1.1.4",
"@vuepic/vue-datepicker": "^9.0.1",
Expand All @@ -10,7 +13,7 @@
"@vueuse/nuxt": "^11.0.3",
"ace-builds": "^1.32.7",
"change-case": "^5.4.4",
"date-fns": "^3.3.1",
"date-fns": "^4.1.0",
"fs-extra": "^11.2.0",
"highlight.js": "^11.8.0",
"highlightjs-curl": "^1.3.0",
Expand All @@ -37,5 +40,13 @@
"unified": "^11.0.4",
"uuid": "^10.0.0",
"web3": "^4.1.2"
},
"devDependencies": {
"@nuxt/test-utils": "^3.14.2",
"@pinia/testing": "^0.1.5",
"@vue/test-utils": "^2.4.6",
"happy-dom": "^15.7.4",
"playwright-core": "^1.47.1",
"vitest": "^2.1.1"
}
}
1 change: 1 addition & 0 deletions packages/zero-core/stores/use-zero-store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ///////////////////////////////////////////////////////////////////// Imports
// -----------------------------------------------------------------------------
import { ref } from '#imports'
import { defineStore } from 'pinia'

// ////////////////////////////////////////////////////////////////////// Export
// -----------------------------------------------------------------------------
Expand Down
27 changes: 27 additions & 0 deletions packages/zero-core/tests/component/use-zero-store.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { setActivePinia, createPinia } from 'pinia'
import { describe, test, expect, beforeAll, beforeEach, afterEach } from 'vitest'
import { useZeroStore } from '@/stores/use-zero-store'

beforeAll(() => {
setActivePinia(createPinia())
})

describe('useZeroStore', () => {
let zeroStore

beforeEach(() => {
zeroStore = useZeroStore()
})

afterEach(() => {
zeroStore.setSeo({})
})

test('creates a store', () => {
expect(zeroStore).toBeDefined()
})

test('initializes with theme light', () => {
expect(zeroStore.seo).toStrictEqual({})
})
})
11 changes: 11 additions & 0 deletions packages/zero-core/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineVitestConfig } from '@nuxt/test-utils/config'

export default defineVitestConfig({
test: {
environment: 'nuxt',
coverage: {
provider: 'v8'
},
include: ['tests/component/*.{test,spec}.?(c|m)[jt]s?(x)']
}
})

0 comments on commit 7d76a84

Please sign in to comment.