-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathplaywright.config.js
More file actions
47 lines (44 loc) · 1.45 KB
/
playwright.config.js
File metadata and controls
47 lines (44 loc) · 1.45 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
import { globSync as findFiles } from 'node:fs';
import { defineConfig } from '@playwright/test';
import fs from 'node:fs';
const port = 7357;
const baseURL = `http://localhost:${port}`;
const reporter = [['list']];
if (process.env.COVERAGE) {
reporter.push(
['monocart-reporter', {
coverage: {
reports: ['text', 'text-summary', 'lcovonly', ['v8', {
metrics: ['lines', 'statements', 'functions', 'branches']
}]],
entryFilter: ({ url }) => url.startsWith(`${baseURL}/src`),
sourcePath: (path) => findFiles(`src/**/${path}`)[0] ?? path,
onEnd: (result) => {
if (fs.existsSync(result.reportPath)) {
let html = fs.readFileSync(result.reportPath, 'utf-8');
const hideUrlColumn = `
<style>
div[column="25"] { display: none; }
</style>`;
// Inject before closing </head>
html = html.replace('</head>', `${hideUrlColumn}</head>`);
fs.writeFileSync(result.reportPath, html, 'utf-8');
}
},
outputDir: 'test/result/report/coverage',
},
outputFile: 'test/result/report/index.html',
}],
['./test/base'],
);
}
export default defineConfig({
use: { baseURL },
webServer: {
url: baseURL,
command: `VITE_HMR=false vite --strictPort --port ${port} --clearScreen false`,
reuseExistingServer: !process.env.CI,
},
reporter,
outputDir: 'test/result',
});