-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvitest.config.js
More file actions
76 lines (74 loc) · 2.71 KB
/
Copy pathvitest.config.js
File metadata and controls
76 lines (74 loc) · 2.71 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
/**
* SPDX-FileCopyrightText: 2026 Conduction / Integriq Contributors
* SPDX-License-Identifier: EUPL-1.2
*
* Vitest configuration for Integriq frontend unit tests.
*
* Post the OR-cutover the app keeps almost no Pinia state (CnIndexPage /
* CnDetailPage manage list/detail state against OR endpoints), so the
* highest-value offline logic now lives in src/handlers/** and the bespoke
* rule action-form helpers (src/views/Rule/actionForms/shared.js):
* • action handlers — POST to the right endpoint, toast success/error.
* • viewLogsHandler — actionId → route + query-param navigation.
* • routerRef — module-scoped router holder (set/get + null-safety).
* • fetchOpenRegisterCollection — OR list-envelope unwrap + option mapping.
* • patchMethod — immutable `update:value` emit for action forms.
*
* These need no DOM, so the environment is `node`. The @nextcloud/* runtime
* deps that aren't mocked per-test are aliased to deterministic stubs; a spec
* that needs a DOM opts in per file with `// @vitest-environment jsdom`.
*
* `@vitejs/plugin-vue` is registered so a spec can import an app `.vue` SFC
* directly (tests/vitest/automationDeprecationNotice.spec.js mounts one).
* Without it Vite hands the SFC to its JS parser and the suite dies at
* import-analysis with "content contains invalid JS syntax" — the component
* under test is never reached, so the failure looks like a broken component
* rather than a missing transform. Specs that mount a PUBLISHED
* @nextcloud/vue component (ncButtonSubmitType) are unaffected either way:
* the library ships compiled ESM, not raw SFCs.
*/
const vuePlugin = require('@vitejs/plugin-vue')
const path = require('path')
module.exports = {
plugins: [(vuePlugin.default ?? vuePlugin)()],
test: {
environment: 'node',
globals: false,
include: ['tests/vitest/**/*.spec.{js,ts}'],
exclude: [
'tests/e2e/**',
'tests/postman/**',
'tests/integration/**',
'src/**',
'node_modules/**',
],
// @nextcloud/vue ships CSS side-effect imports next to its components.
// Node's ESM loader cannot resolve a ".css" specifier, so the package
// must be transformed by Vite rather than externalised, otherwise any
// spec importing a real component dies with ERR_UNKNOWN_FILE_EXTENSION.
server: {
deps: {
inline: [/@nextcloud\/vue/],
},
},
},
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, 'src') },
{
find: /^@nextcloud\/l10n$/,
replacement: path.resolve(
__dirname,
'tests/vitest/stubs/nextcloud-l10n.js',
),
},
{
find: /^@nextcloud\/router$/,
replacement: path.resolve(
__dirname,
'tests/vitest/stubs/nextcloud-router.js',
),
},
],
},
}