Skip to content

Commit 5af4913

Browse files
authored
chore: watch mode improvements (#7326)
1 parent 2e03bc3 commit 5af4913

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

e2e/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,15 @@ A single e2e test in Open MCT is extended to run:
574574
- How is Open MCT extending default Playwright functionality?
575575
- What about Component Testing?
576576
577+
### Writing Tests
578+
579+
Playwright provides 3 supported methods of debugging and authoring tests:
580+
- A 'watch mode' for running tests locally and debugging on the fly
581+
- A 'debug mode' for debugging tests and writing assertions against tests
582+
- A 'VSCode plugin' for debugging tests within the VSCode IDE.
583+
584+
Generally, we encourage folks to use the watch mode and provide a script `npm run test:e2e:watch` which launches the launch mode ui and enables hot reloading on the dev server.
585+
577586
### e2e Troubleshooting
578587
579588
Please follow the general guide troubleshooting in [the general troubleshooting doc](../TESTING.md#troubleshooting-ci)

e2e/playwright-watch.config.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* eslint-disable no-undef */
2+
// playwright.config.js
3+
// @ts-check
4+
5+
// eslint-disable-next-line no-unused-vars
6+
const { devices } = require('@playwright/test');
7+
const MAX_FAILURES = 5;
8+
const NUM_WORKERS = 2;
9+
10+
/** @type {import('@playwright/test').PlaywrightTestConfig} */
11+
const config = {
12+
retries: 0, //Retries 2 times for a total of 3 runs. When running sharded and with max-failures=5, this should ensure that flake is managed without failing the full suite
13+
testDir: 'tests',
14+
timeout: 60 * 1000,
15+
webServer: {
16+
command: 'npm run start', //Start in dev mode for hot reloading
17+
url: 'http://localhost:8080/#',
18+
timeout: 200 * 1000,
19+
reuseExistingServer: true //This was originally disabled to prevent differences in local debugging vs. CI. However, it significantly speeds up local debugging.
20+
},
21+
maxFailures: MAX_FAILURES, //Limits failures to 5 to reduce CI Waste
22+
workers: NUM_WORKERS, //Limit to 2 for CircleCI Agent
23+
use: {
24+
baseURL: 'http://localhost:8080/',
25+
headless: true,
26+
ignoreHTTPSErrors: true,
27+
screenshot: 'only-on-failure',
28+
trace: 'on-first-retry',
29+
video: 'off'
30+
},
31+
projects: [
32+
{
33+
name: 'chrome',
34+
testMatch: '**/*.spec.js', // run all tests
35+
use: {
36+
browserName: 'chromium'
37+
}
38+
}
39+
],
40+
reporter: [
41+
['list'],
42+
[
43+
'html',
44+
{
45+
open: 'never',
46+
outputFolder: '../html-test-results' //Must be in different location due to https://github.com/microsoft/playwright/issues/12840
47+
}
48+
],
49+
['junit', { outputFile: '../test-results/results.xml' }],
50+
['@deploysentinel/playwright']
51+
]
52+
};
53+
54+
module.exports = config;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"test:e2e:visual:ci": "percy exec --config ./e2e/.percy.ci.yml --partial -- npx playwright test --config=e2e/playwright-visual-a11y.config.js --project=chrome --grep-invert @unstable",
116116
"test:e2e:visual:full": "percy exec --config ./e2e/.percy.nightly.yml -- npx playwright test --config=e2e/playwright-visual-a11y.config.js --grep-invert @unstable",
117117
"test:e2e:full": "npx playwright test --config=e2e/playwright-ci.config.js --grep-invert @couchdb",
118-
"test:e2e:watch": "npx playwright test --ui --config=e2e/playwright-ci.config.js",
118+
"test:e2e:watch": "npx playwright test --ui --config=e2e/playwright-watch.config.js",
119119
"test:perf:contract": "npx playwright test --config=e2e/playwright-performance-dev.config.js",
120120
"test:perf:localhost": "npx playwright test --config=e2e/playwright-performance-prod.config.js --project=chrome",
121121
"test:perf:memory": "npx playwright test --config=e2e/playwright-performance-prod.config.js --project=chrome-memory",

0 commit comments

Comments
 (0)