set up import maps aliases in tests

This commit is contained in:
Mads Rasmussen
2022-10-18 14:03:42 +02:00
parent aa3a03eca8
commit d6c9a050f3
5 changed files with 76 additions and 14 deletions

View File

@@ -1,22 +1,40 @@
import { esbuildPlugin } from '@web/dev-server-esbuild';
import { playwrightLauncher } from '@web/test-runner-playwright';
import { importMapsPlugin } from '@web/dev-server-import-maps';
export default {
nodeResolve: true,
files: 'src/**/*.test.ts',
plugins: [esbuildPlugin({ ts: true, target: 'auto' })],
browsers: [
playwrightLauncher({ product: 'chromium' }),
playwrightLauncher({ product: 'firefox' }),
playwrightLauncher({ product: 'webkit' }),
],
nodeResolve: true,
files: 'src/**/*.test.ts',
plugins: [
esbuildPlugin({ ts: true, target: 'auto' }),
importMapsPlugin({
inject: {
importMap: {
imports: {
'@umbraco-cms/models': './src/core/models/index.ts',
'@umbraco-cms/backend-api': './src/core/backend-api/index.ts',
'@umbraco-cms/context-api': './src/core/context-api/index.ts',
'@umbraco-cms/extensions-api': './src/core/extensions-api/index.ts',
'@umbraco-cms/observable-api': './src/core/observable-api/index.ts',
'@umbraco-cms/utils': './src/core/utils/index.ts',
'@umbraco-cms/test-utils': './src/core/test-utils/index.ts',
},
},
},
}),
],
browsers: [
playwrightLauncher({ product: 'chromium' }),
playwrightLauncher({ product: 'firefox' }),
playwrightLauncher({ product: 'webkit' }),
],
coverageConfig: {
reporters: ['lcovonly', 'text-summary'],
},
testRunnerHtml: (testFramework) =>
`<html>
testRunnerHtml: (testFramework) =>
`<html>
<head>
<link rel="stylesheet" href="/src/css/custom-properties.css">
<link rel="stylesheet" href="/src/core/css/custom-properties.css">
</head>
<body>
<script type="module" src="${testFramework}"></script>