-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathvitest.config.ts
60 lines (58 loc) · 1.51 KB
/
vitest.config.ts
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
import tailwindcss from '@tailwindcss/vite';
import path from 'node:path';
import {defineConfig} from 'vitest/config';
//@ts-expect-error - normal json import
import packageJson from './package.json' with {type: 'json'};
const port = 63315;
const resourceUrl = `http://localhost:${port}/`;
export default defineConfig({
define: {
'import.meta.env.RESOURCE_URL': `"${resourceUrl}"`,
__ATOMIC_VERSION__: `"${packageJson.version}"`,
__HEADLESS_VERSION__: `"${packageJson.dependencies['@coveo/headless']}"`,
},
server: {
port: port,
},
resolve: {
alias: {
'@': path.resolve(import.meta.dirname, './'),
},
},
plugins: [
{
name: 'force-inline-css-imports',
enforce: 'pre',
transform(code, id) {
if (id.endsWith('.ts')) {
return {
code: code.replace(
/import\s+([^'"]+)\s+from\s+['"]([^'"]+\.css)['"]/g,
(_, importName, cssPath) =>
`import ${importName} from '${cssPath}?inline'`
),
map: null,
};
}
return null;
},
},
tailwindcss(),
],
test: {
include: ['src/**/*.spec.ts', 'scripts/stencil-proxy.spec.mjs'],
exclude: [
'src/**/initialization-utils.spec.ts',
'src/**/search-layout.spec.ts',
],
setupFiles: ['./vitest-utils/setup.ts'],
globals: true,
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
// https://playwright.dev
providerOptions: {},
},
},
});