-
Notifications
You must be signed in to change notification settings - Fork 836
Expand file tree
/
Copy pathplaywright.config.js
More file actions
48 lines (44 loc) · 1.35 KB
/
playwright.config.js
File metadata and controls
48 lines (44 loc) · 1.35 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
48
// @ts-check
const net = require('node:net');
const path = require('node:path');
const { defineConfig } = require('@playwright/test');
const E2E_DB = path.join(__dirname, 'tests', 'e2e', 'e2e.db');
function getFreePort() {
const srv = net.createServer();
srv.listen(0);
const port = srv.address().port;
srv.close();
return port;
}
// Cache the port in an env var so Playwright workers (separate processes that
// re-evaluate this config) use the same port as the main process.
if (!process.env._PLAYWRIGHT_PORT) {
process.env._PLAYWRIGHT_PORT = String(getFreePort());
}
const port = Number(process.env._PLAYWRIGHT_PORT);
module.exports = defineConfig({
testDir: 'tests/e2e',
testMatch: '*.spec.js',
snapshotPathTemplate: '{testDir}/snapshots/{arg}{ext}',
reporter: [['html', { open: 'never' }]],
outputDir: 'test-results',
projects: [
{
name: 'chromium',
use: { browserName: 'chromium' },
},
],
webServer: {
command:
'test -f .venv/bin/activate && . .venv/bin/activate; python runserver.py',
url: `http://127.0.0.1:${port}`,
reuseExistingServer: false,
env: { PORT: String(port), DEBUG: 'false', DB_PATH: E2E_DB },
},
use: {
baseURL: `http://127.0.0.1:${port}`,
},
expect: {
toHaveScreenshot: {},
},
});