test(ui): register $ver global in vitest setup
Component tests mounted without main.ts's bootstrap, so the $ver global template helper (app.config.globalProperties.$ver = displayVersion) was undefined — AppSidebar/AppHeroSection/MarketplaceAppCard tests failed with "_ctx.$ver is not a function", blocking the release gate's ui-unit-tests stage. Add a vitest setup file that mirrors main.ts via config.global.mocks and wire it into vitest.config.ts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
371be4a69c
commit
b59c74adfe
@ -12,6 +12,7 @@ export default defineConfig({
|
|||||||
test: {
|
test: {
|
||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
globals: true,
|
globals: true,
|
||||||
|
setupFiles: ['./vitest.setup.ts'],
|
||||||
root: '.',
|
root: '.',
|
||||||
passWithNoTests: true,
|
passWithNoTests: true,
|
||||||
exclude: ['e2e/**', 'node_modules/**', '**/._*'],
|
exclude: ['e2e/**', 'node_modules/**', '**/._*'],
|
||||||
|
|||||||
9
neode-ui/vitest.setup.ts
Normal file
9
neode-ui/vitest.setup.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { config } from '@vue/test-utils'
|
||||||
|
import { displayVersion } from '@/utils/version'
|
||||||
|
|
||||||
|
// The app registers `$ver` as a global template property in main.ts
|
||||||
|
// (app.config.globalProperties.$ver = displayVersion). Component tests mount
|
||||||
|
// without that bootstrap, so provide the same global here for every mounted
|
||||||
|
// component. Per-mount `global` options merge with this, so individual tests
|
||||||
|
// keep their own plugins/mocks.
|
||||||
|
config.global.mocks = { ...(config.global.mocks ?? {}), $ver: displayVersion }
|
||||||
Loading…
x
Reference in New Issue
Block a user