Skip to content

Commit c5e5f8c

Browse files
[test optimization] Improve playwright flakiness (this time for real?) (#5440)
1 parent 5e794c7 commit c5e5f8c

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

.github/workflows/project.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,32 @@ jobs:
6161
env:
6262
DD_INJECTION_ENABLED: 'true'
6363

64+
integration-playwright:
65+
strategy:
66+
matrix:
67+
version: [18, latest]
68+
runs-on: ubuntu-latest
69+
env:
70+
DD_SERVICE: dd-trace-js-integration-tests
71+
DD_CIVISIBILITY_AGENTLESS_ENABLED: 1
72+
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_APP }}
73+
steps:
74+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
75+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
76+
with:
77+
node-version: ${{ matrix.version }}
78+
- uses: ./.github/actions/install
79+
# Install system dependencies for playwright
80+
- run: npx playwright install-deps
81+
- run: yarn test:integration:playwright
82+
env:
83+
NODE_OPTIONS: '-r ./ci/init'
84+
6485
integration-ci:
6586
strategy:
6687
matrix:
6788
version: [18, latest]
68-
framework: [cucumber, playwright, selenium, jest, mocha]
89+
framework: [cucumber, selenium, jest, mocha]
6990
runs-on: ubuntu-latest
7091
env:
7192
DD_SERVICE: dd-trace-js-integration-tests
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { test, expect } = require('@playwright/test')
2+
3+
test.beforeEach(async ({ page }) => {
4+
await page.goto(process.env.PW_BASE_URL)
5+
})
6+
7+
test('should work with passing tests', async ({ page }) => {
8+
await expect(page.locator('.hello-world')).toHaveText([
9+
'Hello World'
10+
])
11+
})

integration-tests/playwright/playwright.spec.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@ versions.forEach((version) => {
4747
let sandbox, cwd, receiver, childProcess, webAppPort
4848

4949
before(async function () {
50-
// bump from 60 to 90 seconds because we also need to install dependencies and download chromium
50+
// bump from 60 to 90 seconds because playwright is heavy
5151
this.timeout(90000)
5252
sandbox = await createSandbox([`@playwright/test@${version}`, 'typescript'], true)
5353
cwd = sandbox.folder
5454
const { NODE_OPTIONS, ...restOfEnv } = process.env
55-
// Install system dependencies
56-
execSync('npx playwright install-deps', { cwd, env: restOfEnv })
5755
// Install chromium (configured in integration-tests/playwright.config.js)
58-
execSync('npx playwright install', { cwd, env: restOfEnv })
56+
// *Be advised*: this means that we'll only be using chromium for this test suite
57+
execSync('npx playwright install chromium', { cwd, env: restOfEnv, stdio: 'inherit' })
5958
webAppPort = await getPort()
6059
webAppServer.listen(webAppPort)
6160
})
@@ -202,7 +201,9 @@ versions.forEach((version) => {
202201
})
203202
})
204203

205-
it('works when tests are compiled to a different location', (done) => {
204+
it('works when tests are compiled to a different location', function (done) {
205+
// this has shown some flakiness
206+
this.retries(1)
206207
let testOutput = ''
207208

208209
receiver.gatherPayloadsMaxTimeout(({ url }) => url === '/api/v2/citestcycle', payloads => {
@@ -215,7 +216,7 @@ versions.forEach((version) => {
215216
assert.include(testOutput, '1 passed')
216217
assert.include(testOutput, '1 skipped')
217218
assert.notInclude(testOutput, 'TypeError')
218-
}).then(() => done()).catch(done)
219+
}, 25000).then(() => done()).catch(done)
219220

220221
childProcess = exec(
221222
'node ./node_modules/typescript/bin/tsc' +
@@ -1082,6 +1083,15 @@ versions.forEach((version) => {
10821083

10831084
context('libraries capabilities', () => {
10841085
it('adds capabilities to tests', (done) => {
1086+
receiver.setKnownTests(
1087+
{
1088+
playwright: {
1089+
'passing-test.js': [
1090+
'should work with passing tests'
1091+
]
1092+
}
1093+
}
1094+
)
10851095
receiver.setSettings({
10861096
flaky_test_retries_enabled: true,
10871097
itr_enabled: false,
@@ -1111,12 +1121,14 @@ versions.forEach((version) => {
11111121
env: {
11121122
...getCiVisAgentlessConfig(receiver.port),
11131123
PW_BASE_URL: `http://localhost:${webAppPort}`,
1124+
TEST_DIR: './ci-visibility/playwright-tests-test-capabilities',
11141125
DD_TEST_SESSION_NAME: 'my-test-session-name'
11151126
},
11161127
stdio: 'pipe'
11171128
}
11181129
)
1119-
childProcess.on('exit', (exitCode) => {
1130+
1131+
childProcess.on('exit', () => {
11201132
eventsPromise.then(() => {
11211133
done()
11221134
}).catch(done)

0 commit comments

Comments
 (0)