-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvitest.config.js
More file actions
86 lines (83 loc) · 2.68 KB
/
Copy pathvitest.config.js
File metadata and controls
86 lines (83 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* SPDX-FileCopyrightText: 2026 Conduction / Stackiq Contributors
* SPDX-License-Identifier: EUPL-1.2
*
* Vitest configuration for Stackiq frontend unit tests.
*
* This OFFLINE suite (no Nextcloud runtime) targets PURE app-local logic that
* the rendered UI exercises end-to-end but never asserts exactly:
* • src/utils/translationBadge.js — language-code normalisation, source-
* language extraction off the OpenRegister `@self` envelope, and the
* translated-from badge decision used by every index view.
* • src/store/modules/navigation.js — the UI navigation Pinia store
* (selected view / organisatie / modal / dialog + the consume-once
* transferData handoff), driven through a real Pinia instance.
* • src/components/*Section.vue — the settings-section SLOT CONTRACT, which
* is the one thing about those components that no other check can see:
* a mis-named slot renders NOTHING and throws no error anywhere.
*
* Most specs need no DOM, so the default environment stays `node`. The specs
* that mount a component opt into jsdom per file with a
* `// @vitest-environment jsdom` docblock, and `@vitejs/plugin-vue` compiles
* the SFCs they import.
*
* The few @nextcloud/* runtime packages a store module or a component drags in
* are aliased to lightweight stubs.
*
* The existing Jest suite (jest + co-located *.spec.js under src/) is
* UNTOUCHED — Vitest only collects tests/vitest/**.
*/
const path = require('path')
// `@vitejs/plugin-vue` v6 is ESM-only while this config is CommonJS, so the
// plugin is pulled in through a dynamic import from an async config factory
// (Vite awaits a config exported as a function).
module.exports = async () => {
const vue = (await import('@vitejs/plugin-vue')).default
return {
plugins: [vue()],
test: {
environment: 'node',
globals: false,
include: ['tests/vitest/**/*.spec.{js,ts}'],
exclude: [
'tests/e2e/**',
'tests/integration/**',
'src/**',
'node_modules/**',
],
},
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, 'src') },
{
find: /^@nextcloud\/router$/,
replacement: path.resolve(
__dirname,
'tests/vitest/stubs/nextcloud-router.js',
),
},
{
find: /^@nextcloud\/dialogs$/,
replacement: path.resolve(
__dirname,
'tests/vitest/stubs/nextcloud-dialogs.js',
),
},
{
find: /^@nextcloud\/l10n$/,
replacement: path.resolve(
__dirname,
'tests/vitest/stubs/nextcloud-l10n.js',
),
},
{
find: /^@nextcloud\/vue$/,
replacement: path.resolve(
__dirname,
'tests/vitest/stubs/nextcloud-vue.js',
),
},
],
},
}
}