Skip to content

[WIP] Setup vitest and nuxt for test suite #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,13 @@ export default defineNuxtConfig({
}
},

compatibilityDate: '2025-02-18'
})
compatibilityDate: '2025-02-18',

// Environment overrides:
$test: {
modules: [
'@nuxt/test-utils/module'
]

}
})
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"test": "nuxt --envName test",
"lint": "eslint ."
},
"dependencies": {
Expand All @@ -19,5 +20,9 @@
"tlv2-ui": "https://github.com/interline-io/tlv2-ui.git#commit=a146ee22b869d229890de2e398e51c05681412f2",
"vue-concurrency": "^5.0.3"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"devDependencies": {
"@nuxt/test-utils": "^3.19.0",
"happy-dom": "^17.4.7"
}
}
22 changes: 22 additions & 0 deletions tests/components/legend.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, it, expect } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import CalLegend from '~/components/cal/legend.vue'

describe('CalLegend', () => {
it('renders properly', async () => {
const wrapper = await mountSuspended(CalLegend)
expect(wrapper.exists()).toBe(true)
})
})


// import { describe, it, expect } from 'vitest'
// import { mount } from '@vue/test-utils'
// import CalLegend from '~/components/cal/legend.vue'

// describe('CalLegend', () => {
// it('renders properly', () => {
// const wrapper = mount(CalLegend)
// expect(wrapper.exists()).toBe(true)
// })
// })
18 changes: 18 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// import { defineConfig } from 'vite'
// import vue from '@vitejs/plugin-vue'

// // https://vitejs.dev/config/
// export default defineConfig({
// plugins: [vue()],
// test: {
// globals: true
// }
// })

import { defineVitestConfig } from '@nuxt/test-utils/config'

export default defineVitestConfig({
test: {
environment: 'nuxt',
}
})
Loading