Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
93 lines (91 loc) · 4.92 KB
/
Copy pathvitest.config.ts
File metadata and controls
93 lines (91 loc) · 4.92 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
87
88
89
90
91
92
93
/**
* Vitest Configuration for Artemis Angular Tests
*
* Uses @analogjs/vite-plugin-angular for Angular compilation with Vitest 4.
*
* The entire Angular client runs on Vitest, so the spec/coverage globs are broad (all of
* src/main/webapp/app) rather than an explicit per-module allowlist. The only exceptions:
* - the Monaco editor *integration* specs run against the real Monaco package and therefore live
* in a separate project (see config/testing/vitest.monaco.config.ts); they are excluded here.
* - generated code (openapi) and non-testable config/model/route files are excluded from coverage.
*/
import { defineConfig } from 'vitest/config';
import angular from '@analogjs/vite-plugin-angular';
import path from 'node:path';
const isCI = process.env.CI === 'true';
export default defineConfig({
// Only show errors, suppress sourcemap warnings from node_modules packages
logLevel: 'error',
resolve: {
alias: {
'monaco-editor': path.resolve(__dirname, 'src/test/javascript/spec/helpers/mocks/mock-monaco-editor.ts'),
app: path.resolve(__dirname, 'src/main/webapp/app'),
test: path.resolve(__dirname, 'src/test/javascript/spec'),
src: path.resolve(__dirname, 'src'),
// The Angular test compiler emits root-relative imports for shared component stylesheets.
'/src': path.resolve(__dirname, 'src'),
// Mirrors the tsconfig `paths` entry: the package's own `exports` map only exposes
// `./styles.css`, so the bare specifier resolves through the built library instead.
'@tumaet/ui-angular': path.resolve(__dirname, 'packages/tum-aet-ui/dist'),
},
},
css: {
// .postcssrc.json (Tailwind) is a production-build concern. Vitest would otherwise auto-load it and run
// PostCSS over every component's inline `styles`, whose SCSS `//` comments are invalid CSS and make PostCSS
// throw. Tests don't need Tailwind generation, so run no PostCSS plugins here.
postcss: { plugins: [] },
preprocessorOptions: {
scss: {
loadPaths: [path.resolve(__dirname)],
silenceDeprecations: ['color-functions', 'global-builtin', 'import', 'if-function'],
},
},
},
// JIT mode required for ng-mocks compatibility; fastCompile is required under Angular 22 so the
// plugin inlines external templateUrl/styleUrl (the two-pass JIT path's compiler markers are gone).
plugins: [angular({ jit: true, fastCompile: true, tsconfig: path.resolve(__dirname, 'config/client/tsconfig.spec.json') })],
test: {
globals: true,
pool: 'forks',
environment: 'jsdom',
setupFiles: ['src/test/javascript/spec/vitest-test-setup.ts'],
include: [
'src/main/webapp/app/**/*.spec.ts', // entire Angular client runs on Vitest
'src/test/javascript/spec/integration/code-editor/**/*.spec.ts', // code-editor integration specs (mock Monaco)
],
// The Monaco editor integration specs need the real Monaco package; they run in config/testing/vitest.monaco.config.ts.
exclude: ['**/node_modules/**', '**/build/**', '**/integration/monaco-editor/**'],
testTimeout: 10000,
reporters: ['default', 'junit'],
outputFile: './build/test-results/vitest/junit.xml',
server: {
deps: {
inline: [/@tumaet\/apollon/, /html-diff-ts/, /monaco-editor/],
},
},
coverage: {
provider: 'istanbul',
reporter: isCI ? ['text', 'lcov', 'json-summary'] : ['text', 'lcov', 'html', 'json-summary'],
reportsDirectory: 'build/test-results/vitest/coverage',
include: ['src/main/webapp/app/**/*.ts'],
exclude: [
'**/node_modules/**', // exclude node_modules with third-party code
'**/*.spec.ts', // exclude test specification files
'**/*.route.ts', // exclude route definition files (not really testable)
'**/*.routes.ts', // exclude route definition files (not really testable)
'**/*.model.ts', // exclude data model files (not really testable)
'src/main/webapp/app/openapi/**', // generated OpenAPI client (not hand-written, not tested)
'src/main/webapp/app/core/config/dayjs.ts', // exclude dayjs configuration file (not really testable)
'src/main/webapp/app/core/config/monaco.config.ts', // exclude monaco configuration file (not really testable)
'src/main/webapp/app/core/config/prod.config.ts', // exclude prod configuration file (not really testable)
],
thresholds: {
// Floors set just below current actuals; ratchet up as coverage improves.
lines: 88.8,
statements: 88.7,
branches: 73.6,
functions: 86.0,
},
},
},
});