forked from umbraco/Umbraco.CMS.Backoffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb-test-runner.config.mjs
173 lines (157 loc) · 9.48 KB
/
web-test-runner.config.mjs
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import { esbuildPlugin } from '@web/dev-server-esbuild';
import { playwrightLauncher } from '@web/test-runner-playwright';
import { importMapsPlugin } from '@web/dev-server-import-maps';
import rollupCommonjs from '@rollup/plugin-commonjs';
import { fromRollup } from '@web/dev-server-rollup';
const commonjs = fromRollup(rollupCommonjs);
const mode = process.env.MODE || 'dev';
if (!['dev', 'prod'].includes(mode)) {
throw new Error(`MODE must be "dev" or "prod", was "${mode}"`);
}
/** @type {import('@web/dev-server').DevServerConfig} */
export default {
rootDir: '.',
files: ['./src/**/*.test.ts'],
nodeResolve: { exportConditions: mode === 'dev' ? ['development'] : [], preferBuiltins: false, browser: true },
browsers: [playwrightLauncher({ product: 'chromium' }), playwrightLauncher({ product: 'webkit' })],
coverageConfig: {
reporters: ['lcovonly', 'text-summary'],
},
plugins: [
esbuildPlugin({ ts: true, tsconfig: './tsconfig.json', target: 'auto', json: true }),
importMapsPlugin({
inject: {
importMap: {
imports: {
'src/': './src/',
'@umbraco-cms/backoffice/app': './src/apps/app/index.ts',
'@umbraco-cms/backoffice/external/lit': './src/external/lit/index.ts',
'@umbraco-cms/backoffice/external/lodash': './src/external/lodash/index.ts',
'@umbraco-cms/backoffice/external/monaco-editor': './src/external/monaco-editor/index.ts',
'@umbraco-cms/backoffice/external/openid': './src/external/openid/index.ts',
'@umbraco-cms/backoffice/external/router-slot': './src/external/router-slot/index.ts',
'@umbraco-cms/backoffice/external/rxjs': './src/external/rxjs/index.ts',
'@umbraco-cms/backoffice/external/tinymce': './src/external/tinymce/index.ts',
'@umbraco-cms/backoffice/external/uui': './src/external/uui/index.ts',
'@umbraco-cms/backoffice/external/uuid': './src/external/uuid/index.ts',
'@umbraco-cms/backoffice/external/dompurify': './src/external/dompurify/index.ts',
'@umbraco-cms/backoffice/external/marked': './src/external/marked/index.ts',
'@umbraco-cms/backoffice/backend-api': './src/external/backend-api/index.ts',
'@umbraco-cms/backoffice/class-api': './src/libs/class-api/index.ts',
'@umbraco-cms/backoffice/context-api': './src/libs/context-api/index.ts',
'@umbraco-cms/backoffice/controller-api': './src/libs/controller-api/index.ts',
'@umbraco-cms/backoffice/element-api': './src/libs/element-api/index.ts',
'@umbraco-cms/backoffice/extension-api': './src/libs/extension-api/index.ts',
'@umbraco-cms/backoffice/localization-api': './src/libs/localization-api/index.ts',
'@umbraco-cms/backoffice/observable-api': './src/libs/observable-api/index.ts',
'@umbraco-cms/backoffice/auth': './src/shared/auth/index.ts',
'@umbraco-cms/backoffice/icon': './src/shared/icon-registry/index.ts',
'@umbraco-cms/backoffice/models': './src/shared/models/index.ts',
'@umbraco-cms/backoffice/resources': './src/shared/resources/index.ts',
'@umbraco-cms/backoffice/router': './src/shared/router/index.ts',
'@umbraco-cms/backoffice/style': './src/shared/style/index.ts',
'@umbraco-cms/backoffice/utils': './src/shared/utils/index.ts',
'@umbraco-cms/internal/lit-element': './src/shared/lit-element/index.ts',
'@umbraco-cms/backoffice/action': './src/packages/core/action/index.ts',
'@umbraco-cms/backoffice/collection': './src/packages/core/collection/index.ts',
'@umbraco-cms/backoffice/components': './src/packages/core/components/index.ts',
'@umbraco-cms/backoffice/content-type': './src/packages/core/content-type/index.ts',
'@umbraco-cms/backoffice/debug': './src/packages/core/debug/index.ts',
'@umbraco-cms/backoffice/entity-action': './src/packages/core/entity-action/index.ts',
'@umbraco-cms/backoffice/entity-bulk-action': './src/packages/core/entity-bulk-action/index.ts',
'@umbraco-cms/backoffice/extension-registry': './src/packages/core/extension-registry/index.ts',
'@umbraco-cms/backoffice/server-file-system': './src/packages/core/server-file-system/index.ts',
'@umbraco-cms/backoffice/id': './src/packages/core/id/index.ts',
'@umbraco-cms/backoffice/localization': './src/packages/core/localization/index.ts',
'@umbraco-cms/backoffice/menu': './src/packages/core/menu/index.ts',
'@umbraco-cms/backoffice/modal': './src/packages/core/modal/index.ts',
'@umbraco-cms/backoffice/notification': './src/packages/core/notification/index.ts',
'@umbraco-cms/backoffice/picker-input': './src/packages/core/picker-input/index.ts',
'@umbraco-cms/backoffice/property': './src/packages/core/property/index.ts',
'@umbraco-cms/backoffice/property-action': './src/packages/core/property-action/index.ts',
'@umbraco-cms/backoffice/property-editor': './src/packages/core/property-editor/index.ts',
'@umbraco-cms/backoffice/section': './src/packages/core/section/index.ts',
'@umbraco-cms/backoffice/sorter': './src/packages/core/sorter/index.ts',
'@umbraco-cms/backoffice/store': './src/packages/core/store/index.ts',
'@umbraco-cms/backoffice/themes': './src/packages/core/themes/index.ts',
'@umbraco-cms/backoffice/tree': './src/packages/core/tree/index.ts',
'@umbraco-cms/backoffice/variant': './src/packages/core/variant/index.ts',
'@umbraco-cms/backoffice/workspace': './src/packages/core/workspace/index.ts',
'@umbraco-cms/backoffice/culture': './src/packages/core/culture/index.ts',
'@umbraco-cms/backoffice/event': './src/packages/core/event/index.ts',
'@umbraco-cms/backoffice/repository': './src/packages/core/repository/index.ts',
'@umbraco-cms/backoffice/temporary-file': './src/packages/core/temporary-file/index.ts',
'@umbraco-cms/backoffice/block': './src/packages/block/index.ts',
'@umbraco-cms/backoffice/audit-log': './src/packages/core/audit-log/index.ts',
'@umbraco-cms/backoffice/dictionary': './src/packages/dictionary/dictionary/index.ts',
'@umbraco-cms/backoffice/document': './src/packages/documents/documents/index.ts',
'@umbraco-cms/backoffice/document-blueprint': './src/packages/documents/document-blueprints/index.ts',
'@umbraco-cms/backoffice/document-type': './src/packages/documents/document-types/index.ts',
'@umbraco-cms/backoffice/media': './src/packages/media/media/index.ts',
'@umbraco-cms/backoffice/media-type': './src/packages/media/media-types/index.ts',
'@umbraco-cms/backoffice/member': './src/packages/members/members/index.ts',
'@umbraco-cms/backoffice/member-group': './src/packages/members/member-groups/index.ts',
'@umbraco-cms/backoffice/member-type': './src/packages/members/member-types/index.ts',
'@umbraco-cms/backoffice/package': './src/packages/packages/package/index.ts',
'@umbraco-cms/backoffice/language': './src/packages/language/index.ts',
'@umbraco-cms/backoffice/data-type': './src/packages/core/data-type/index.ts',
'@umbraco-cms/backoffice/dynamic-root': './src/packages/dynamic-root/index.ts',
'@umbraco-cms/backoffice/logviewer': './src/packages/settings/logviewer/index.ts',
'@umbraco-cms/backoffice/relation-type': './src/packages/relations/relation-types/index.ts',
'@umbraco-cms/backoffice/relation': './src/packages/relations/relations/index.ts',
'@umbraco-cms/backoffice/tags': './src/packages/tags/index.ts',
'@umbraco-cms/backoffice/static-file': './src/packages/static-file/index.ts',
'@umbraco-cms/backoffice/partial-view': './src/packages/templating/partial-views/index.ts',
'@umbraco-cms/backoffice/stylesheet': './src/packages/templating/stylesheets/index.ts',
'@umbraco-cms/backoffice/template': './src/packages/templating/templates/index.ts',
'@umbraco-cms/backoffice/user-group': './src/packages/user/user-group/index.ts',
'@umbraco-cms/backoffice/current-user': './src/packages/user/current-user/index.ts',
'@umbraco-cms/backoffice/user': './src/packages/user/user/index.ts',
'@umbraco-cms/backoffice/user-permission': './src/packages/user/user-permission/index.ts',
'@umbraco-cms/backoffice/code-editor': './src/packages/templating/code-editor/index.ts',
'@umbraco-cms/internal/test-utils': './utils/test-utils.ts',
},
},
},
}),
commonjs({
include: ['node_modules/**', 'src/external/**'],
}),
],
testRunnerHtml: (testFramework, devMode) =>
`<html lang="en-us">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="src/assets/favicon.svg" />
<title>Umbraco</title>
<base href="/" />
<script>
window.__UMBRACO_TEST_RUN_A11Y_TEST = ${(!devMode).toString()};
</script>
<script src="/node_modules/msw/lib/iife/index.js"></script>
<link rel="stylesheet" href="node_modules/@umbraco-ui/uui-css/dist/uui-css.css">
<link rel="stylesheet" href="src/css/umb-css.css">
</head>
<body>
<script type="module" src="${testFramework}"></script>
<script type="module">
/* Hack to disable Lit dev mode warnings */
const systemWarn = window.console.warn;
window.console.warn = (...args) => {
if (args[0].indexOf('Lit is in dev mode.') === 0) {
return;
}
if (args[0].indexOf('Multiple versions of Lit loaded.') === 0) {
return;
}
systemWarn(...args);
};
</script>
<script type="module">
import 'element-internals-polyfill';
import '@umbraco-ui/uui';
</script>
</body>
</html>`,
};