test: set up vitest for n-link-core components

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Your Name 2026-07-23 06:28:10 -04:00
parent 9b71c3ba76
commit 8578541f1e
4 changed files with 1976 additions and 1 deletions

View file

@ -7,7 +7,8 @@
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"tauri": "tauri"
"tauri": "tauri",
"test": "vitest run"
},
"dependencies": {
"@tauri-apps/api": "^2.11.1",
@ -23,12 +24,15 @@
"@tailwindcss/forms": "^0.5.11",
"@tauri-apps/cli": "^2",
"@vitejs/plugin-vue": "^5.2.1",
"@vue/test-utils": "^2.4.6",
"autoprefixer": "^10.5.4",
"happy-dom": "^15.11.7",
"postcss": "^8.5.21",
"sass": "^1.101.3",
"tailwindcss": "^3.4.19",
"typescript": "~5.6.2",
"vite": "^6.0.3",
"vitest": "^2.1.8",
"vue-tsc": "^2.1.10"
}
}

16
desktop/vitest.config.ts Normal file
View file

@ -0,0 +1,16 @@
import { defineConfig } from 'vitest/config';
import vue from '@vitejs/plugin-vue';
import { fileURLToPath, URL } from 'node:url';
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'n-link-core': fileURLToPath(new URL('../n-link-core', import.meta.url)),
},
},
test: {
environment: 'happy-dom',
include: ['../n-link-core/components/**/*.spec.ts', 'src/**/*.spec.ts'],
},
});

View file

@ -0,0 +1,11 @@
import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import { defineComponent, h } from 'vue';
describe('vitest setup', () => {
it('mounts a component', () => {
const C = defineComponent({ render: () => h('div', 'hello') });
const wrapper = mount(C);
expect(wrapper.text()).toBe('hello');
});
});

1944
package-lock.json generated

File diff suppressed because it is too large Load diff