2022-05-24 16:14:15 +02:00
|
|
|
import { esbuildPlugin } from '@web/dev-server-esbuild';
|
|
|
|
|
import { playwrightLauncher } from '@web/test-runner-playwright';
|
2022-10-18 14:03:42 +02:00
|
|
|
import { importMapsPlugin } from '@web/dev-server-import-maps';
|
2024-02-10 23:05:05 +01:00
|
|
|
import { createImportMap } from './devops/importmap/index.js';
|
2023-11-08 12:03:50 +01:00
|
|
|
|
2023-08-02 16:54:48 +02:00
|
|
|
const mode = process.env.MODE || 'dev';
|
|
|
|
|
if (!['dev', 'prod'].includes(mode)) {
|
|
|
|
|
throw new Error(`MODE must be "dev" or "prod", was "${mode}"`);
|
|
|
|
|
}
|
2023-02-10 09:33:32 +01:00
|
|
|
|
2024-11-29 13:21:00 +01:00
|
|
|
const silencedLogs = [
|
|
|
|
|
'Lit is in dev mode.',
|
|
|
|
|
'Multiple versions of Lit loaded.',
|
|
|
|
|
'-- Extension of alias "',
|
|
|
|
|
'Error: Failed to create extension api from alias',
|
|
|
|
|
'Documentation: ',
|
|
|
|
|
'Found an issue? https://github.com/mswjs/msw/issues',
|
|
|
|
|
'Worker script URL:',
|
|
|
|
|
'Worker scope:',
|
|
|
|
|
];
|
2024-07-03 11:57:13 +02:00
|
|
|
|
2023-02-10 09:33:32 +01:00
|
|
|
/** @type {import('@web/dev-server').DevServerConfig} */
|
2022-05-24 16:14:15 +02:00
|
|
|
export default {
|
2023-08-02 16:54:48 +02:00
|
|
|
rootDir: '.',
|
2025-06-12 13:24:11 +02:00
|
|
|
files: ['./src/**/*.test.ts', '!**/node_modules/**'],
|
2024-05-22 11:56:19 +02:00
|
|
|
nodeResolve: { exportConditions: mode === 'dev' ? ['development'] : [], preferBuiltins: false, browser: false },
|
2025-01-16 15:50:09 +01:00
|
|
|
browsers: [playwrightLauncher({ product: 'chromium' })],
|
2024-07-04 13:28:37 +02:00
|
|
|
/* TODO: fix coverage report
|
2023-12-08 12:36:46 +01:00
|
|
|
coverageConfig: {
|
|
|
|
|
reporters: ['lcovonly', 'text-summary'],
|
|
|
|
|
},
|
2024-07-04 13:28:37 +02:00
|
|
|
*/
|
2022-10-18 14:03:42 +02:00
|
|
|
plugins: [
|
|
|
|
|
importMapsPlugin({
|
|
|
|
|
inject: {
|
2024-02-10 23:05:05 +01:00
|
|
|
importMap: createImportMap({
|
2024-02-11 22:16:03 +01:00
|
|
|
rootDir: './src',
|
|
|
|
|
additionalImports: {
|
2023-04-12 17:05:14 +02:00
|
|
|
'@umbraco-cms/internal/test-utils': './utils/test-utils.ts',
|
2022-10-18 14:03:42 +02:00
|
|
|
},
|
2024-02-13 11:57:03 +01:00
|
|
|
replaceModuleExtensions: true,
|
2024-02-10 23:05:05 +01:00
|
|
|
}),
|
2022-10-18 14:03:42 +02:00
|
|
|
},
|
|
|
|
|
}),
|
2024-04-09 17:16:52 +02:00
|
|
|
esbuildPlugin({ ts: true, tsconfig: './tsconfig.json', target: 'auto', json: true }),
|
2022-10-18 14:03:42 +02:00
|
|
|
],
|
2024-07-03 11:57:13 +02:00
|
|
|
filterBrowserLogs(log) {
|
|
|
|
|
for (const arg of log.args) {
|
|
|
|
|
if (typeof arg === 'string' && silencedLogs.some((l) => arg.includes(l))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
},
|
2023-12-07 13:23:33 +01:00
|
|
|
testRunnerHtml: (testFramework, devMode) =>
|
2023-07-31 17:27:49 +02:00
|
|
|
`<html lang="en-us">
|
2022-08-10 12:03:01 +02:00
|
|
|
<head>
|
2023-01-18 11:19:51 +01:00
|
|
|
<meta charset="UTF-8" />
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
2023-05-25 10:55:09 +02:00
|
|
|
<link rel="icon" type="image/svg+xml" href="src/assets/favicon.svg" />
|
2023-01-18 11:19:51 +01:00
|
|
|
<title>Umbraco</title>
|
|
|
|
|
<base href="/" />
|
2023-12-07 13:23:33 +01:00
|
|
|
<script>
|
2023-12-07 14:03:13 +01:00
|
|
|
window.__UMBRACO_TEST_RUN_A11Y_TEST = ${(!devMode).toString()};
|
2023-12-07 13:23:33 +01:00
|
|
|
</script>
|
2023-05-15 11:49:17 +02:00
|
|
|
<script src="/node_modules/msw/lib/iife/index.js"></script>
|
2024-11-29 13:21:00 +01:00
|
|
|
<script type="module" src="/web-test-runner.index.ts"></script>
|
2023-01-18 11:19:51 +01:00
|
|
|
<link rel="stylesheet" href="node_modules/@umbraco-ui/uui-css/dist/uui-css.css">
|
2023-05-25 10:55:09 +02:00
|
|
|
<link rel="stylesheet" href="src/css/umb-css.css">
|
2024-05-29 20:07:33 +02:00
|
|
|
<script type="module">
|
|
|
|
|
import '@umbraco-cms/backoffice/components';
|
|
|
|
|
</script>
|
2022-08-10 12:03:01 +02:00
|
|
|
</head>
|
2022-05-24 16:14:15 +02:00
|
|
|
<body>
|
|
|
|
|
<script type="module" src="${testFramework}"></script>
|
2022-08-09 15:38:53 +02:00
|
|
|
<script type="module">
|
|
|
|
|
import 'element-internals-polyfill';
|
|
|
|
|
import '@umbraco-ui/uui';
|
2022-05-25 13:11:54 +02:00
|
|
|
</script>
|
2022-05-24 16:14:15 +02:00
|
|
|
</body>
|
|
|
|
|
</html>`,
|
|
|
|
|
};
|