Skip to content

Commit 12299c9

Browse files
authored
chore(tests): Update Playwright to 1.40.1 in browser integration tests (#10175)
1 parent c078676 commit 12299c9

File tree

63 files changed

+241
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+241
-242
lines changed

dev-packages/browser-integration-tests/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
"private": true,
1010
"scripts": {
1111
"clean": "rimraf -g suites/**/dist loader-suites/**/dist tmp",
12-
"install-browsers": "playwright install --with-deps",
12+
"install-browsers": "npx playwright install --with-deps",
1313
"lint": "eslint . --format stylish",
1414
"fix": "eslint . --format stylish --fix",
1515
"type-check": "tsc",
16+
"postinstall": "yarn install-browsers",
1617
"pretest": "yarn clean && yarn type-check",
17-
"test": "playwright test ./suites --project='chromium'",
18-
"test:all": "playwright test ./suites",
18+
"test": "yarn test:all --project='chromium'",
19+
"test:all": "npx playwright test -c playwright.browser.config.ts",
1920
"test:bundle:es5": "PW_BUNDLE=bundle_es5 yarn test",
2021
"test:bundle:es5:min": "PW_BUNDLE=bundle_es5_min yarn test",
2122
"test:bundle:es6": "PW_BUNDLE=bundle_es6 yarn test",
@@ -30,29 +31,28 @@
3031
"test:bundle:tracing:replay:es6:min": "PW_BUNDLE=bundle_tracing_replay_es6_min yarn test",
3132
"test:cjs": "PW_BUNDLE=cjs yarn test",
3233
"test:esm": "PW_BUNDLE=esm yarn test",
33-
"test:loader": "playwright test ./loader-suites --project='chromium'",
34+
"test:loader": "npx playwright test -c playwright.loader.config.ts --project='chromium'",
3435
"test:loader:base": "PW_BUNDLE=loader_base yarn test:loader",
3536
"test:loader:eager": "PW_BUNDLE=loader_eager yarn test:loader",
3637
"test:loader:tracing": "PW_BUNDLE=loader_tracing yarn test:loader",
3738
"test:loader:replay": "PW_BUNDLE=loader_replay yarn test:loader",
3839
"test:loader:full": "PW_BUNDLE=loader_tracing_replay yarn test:loader",
3940
"test:loader:debug": "PW_BUNDLE=loader_debug yarn test:loader",
40-
"test:ci": "playwright test ./suites --reporter='line'",
41+
"test:ci": "yarn test:all --reporter='line'",
4142
"test:update-snapshots": "yarn test:all --update-snapshots",
4243
"test:detect-flaky": "ts-node scripts/detectFlakyTests.ts",
4344
"validate:es5": "es-check es5 'fixtures/loader.js'"
4445
},
4546
"dependencies": {
4647
"@babel/preset-typescript": "^7.16.7",
47-
"@playwright/test": "^1.31.1",
48+
"@playwright/test": "^1.40.1",
4849
"@sentry-internal/rrweb": "2.9.0",
4950
"@sentry/browser": "7.97.0",
5051
"@sentry/tracing": "7.97.0",
5152
"axios": "1.6.0",
5253
"babel-loader": "^8.2.2",
5354
"html-webpack-plugin": "^5.5.0",
5455
"pako": "^2.1.0",
55-
"playwright": "^1.31.1",
5656
"webpack": "^5.52.0"
5757
},
5858
"devDependencies": {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { PlaywrightTestConfig } from '@playwright/test';
2+
import CorePlaywrightConfig from './playwright.config';
3+
4+
const config: PlaywrightTestConfig = {
5+
...CorePlaywrightConfig,
6+
testDir: './suites',
7+
};
8+
9+
export default config;

dev-packages/browser-integration-tests/playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const config: PlaywrightTestConfig = {
88
// Use 3 workers on CI, else use defaults (based on available CPU cores)
99
// Note that 3 is a random number selected to work well with our CI setup
1010
workers: process.env.CI ? 3 : undefined,
11+
testMatch: /test.ts/,
1112

1213
projects: [
1314
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { PlaywrightTestConfig } from '@playwright/test';
2+
import CorePlaywrightConfig from './playwright.config';
3+
4+
const config: PlaywrightTestConfig = {
5+
...CorePlaywrightConfig,
6+
testDir: './loader-suites',
7+
};
8+
9+
export default config;

dev-packages/browser-integration-tests/scripts/detectFlakyTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ${changedPaths.join('\n')}
4343
try {
4444
await new Promise<void>((resolve, reject) => {
4545
const cp = childProcess.spawn(
46-
`yarn playwright test ${
46+
`npx playwright test ${
4747
testPaths.length ? testPaths.join(' ') : './suites'
4848
} --reporter='line' --repeat-each ${runCount}`,
4949
{ shell: true, cwd },

dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/click/test.ts

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,58 @@ import type { Event } from '@sentry/types';
44
import { sentryTest } from '../../../../../utils/fixtures';
55
import { getFirstSentryEnvelopeRequest } from '../../../../../utils/helpers';
66

7-
sentryTest(
8-
'captures Breadcrumb for clicks & debounces them for a second',
9-
async ({ getLocalTestUrl, page, browserName }) => {
10-
sentryTest.skip(browserName === 'chromium', 'This consistently flakes on chrome.');
11-
12-
const url = await getLocalTestUrl({ testDir: __dirname });
13-
14-
await page.route('**/foo', route => {
15-
return route.fulfill({
16-
status: 200,
17-
body: JSON.stringify({
18-
userNames: ['John', 'Jane'],
19-
}),
20-
headers: {
21-
'Content-Type': 'application/json',
22-
},
23-
});
24-
});
25-
26-
const promise = getFirstSentryEnvelopeRequest<Event>(page);
27-
28-
await page.goto(url);
29-
30-
await page.click('#button1');
31-
// not debounced because other target
32-
await page.click('#button2');
33-
// This should be debounced
34-
await page.click('#button2');
35-
36-
// Wait a second for the debounce to finish
37-
await page.waitForTimeout(1000);
38-
await page.click('#button2');
39-
40-
const [eventData] = await Promise.all([promise, page.evaluate('Sentry.captureException("test exception")')]);
41-
42-
expect(eventData.exception?.values).toHaveLength(1);
43-
44-
expect(eventData.breadcrumbs).toEqual([
45-
{
46-
timestamp: expect.any(Number),
47-
category: 'ui.click',
48-
message: 'body > button#button1[type="button"]',
49-
},
50-
{
51-
timestamp: expect.any(Number),
52-
category: 'ui.click',
53-
message: 'body > button#button2[type="button"]',
54-
},
55-
{
56-
timestamp: expect.any(Number),
57-
category: 'ui.click',
58-
message: 'body > button#button2[type="button"]',
7+
sentryTest('captures Breadcrumb for clicks & debounces them for a second', async ({ getLocalTestUrl, page }) => {
8+
const url = await getLocalTestUrl({ testDir: __dirname });
9+
10+
await page.route('**/foo', route => {
11+
return route.fulfill({
12+
status: 200,
13+
body: JSON.stringify({
14+
userNames: ['John', 'Jane'],
15+
}),
16+
headers: {
17+
'Content-Type': 'application/json',
5918
},
60-
]);
61-
},
62-
);
19+
});
20+
});
21+
22+
const promise = getFirstSentryEnvelopeRequest<Event>(page);
23+
24+
await page.goto(url);
25+
26+
await page.locator('#button1').click();
27+
28+
// not debounced because other target
29+
await page.locator('#button2').click();
30+
// This should be debounced
31+
await page.locator('#button2').click();
32+
33+
// Wait a second for the debounce to finish
34+
await page.waitForTimeout(1000);
35+
await page.locator('#button2').click();
36+
37+
const [eventData] = await Promise.all([promise, page.evaluate('Sentry.captureException("test exception")')]);
38+
39+
expect(eventData.exception?.values).toHaveLength(1);
40+
41+
expect(eventData.breadcrumbs).toEqual([
42+
{
43+
timestamp: expect.any(Number),
44+
category: 'ui.click',
45+
message: 'body > button#button1[type="button"]',
46+
},
47+
{
48+
timestamp: expect.any(Number),
49+
category: 'ui.click',
50+
message: 'body > button#button2[type="button"]',
51+
},
52+
{
53+
timestamp: expect.any(Number),
54+
category: 'ui.click',
55+
message: 'body > button#button2[type="button"]',
56+
},
57+
]);
58+
});
6359

6460
sentryTest(
6561
'uses the annotated component name in the breadcrumb messages and adds it to the data object',
@@ -81,7 +77,7 @@ sentryTest(
8177
const promise = getFirstSentryEnvelopeRequest<Event>(page);
8278

8379
await page.goto(url);
84-
await page.click('#annotated-button');
80+
await page.locator('#annotated-button').click();
8581
await page.evaluate('Sentry.captureException("test exception")');
8682

8783
const eventData = await promise;

dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/dom/textInput/test.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@ sentryTest('captures Breadcrumb for events on inputs & debounced them', async ({
2323

2424
await page.goto(url);
2525

26-
await page.click('#input1');
2726
// Not debounced because other event type
28-
await page.type('#input1', 'John', { delay: 1 });
27+
await page.locator('#input1').pressSequentially('John', { delay: 1 });
28+
2929
// This should be debounced
30-
await page.type('#input1', 'Abby', { delay: 1 });
30+
await page.locator('#input1').pressSequentially('Abby', { delay: 1 });
31+
3132
// not debounced because other target
32-
await page.type('#input2', 'Anne', { delay: 1 });
33+
await page.locator('#input2').pressSequentially('Anne', { delay: 1 });
3334

3435
// Wait a second for the debounce to finish
3536
await page.waitForTimeout(1000);
36-
await page.type('#input2', 'John', { delay: 1 });
37+
await page.locator('#input2').pressSequentially('John', { delay: 1 });
3738

3839
await page.evaluate('Sentry.captureException("test exception")');
3940

@@ -42,11 +43,6 @@ sentryTest('captures Breadcrumb for events on inputs & debounced them', async ({
4243
expect(eventData.exception?.values).toHaveLength(1);
4344

4445
expect(eventData.breadcrumbs).toEqual([
45-
{
46-
timestamp: expect.any(Number),
47-
category: 'ui.click',
48-
message: 'body > input#input1[type="text"]',
49-
},
5046
{
5147
timestamp: expect.any(Number),
5248
category: 'ui.input',
@@ -86,20 +82,13 @@ sentryTest(
8682

8783
await page.goto(url);
8884

89-
await page.click('#annotated-input');
90-
await page.type('#annotated-input', 'John', { delay: 1 });
85+
await page.locator('#annotated-input').pressSequentially('John', { delay: 1 });
9186

9287
await page.evaluate('Sentry.captureException("test exception")');
9388
const eventData = await promise;
9489
expect(eventData.exception?.values).toHaveLength(1);
9590

9691
expect(eventData.breadcrumbs).toEqual([
97-
{
98-
timestamp: expect.any(Number),
99-
category: 'ui.click',
100-
message: 'body > AnnotatedInput',
101-
data: { 'ui.component_name': 'AnnotatedInput' },
102-
},
10392
{
10493
timestamp: expect.any(Number),
10594
category: 'ui.input',

dev-packages/browser-integration-tests/suites/integrations/ContextLines/inline/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sentryTest(
1919

2020
const eventReqPromise = waitForErrorRequestOnUrl(page, url);
2121

22-
const clickPromise = page.click('#inline-error-btn');
22+
const clickPromise = page.locator('#inline-error-btn').click();
2323

2424
const [req] = await Promise.all([eventReqPromise, clickPromise]);
2525

dev-packages/browser-integration-tests/suites/integrations/ContextLines/noAddedLines/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sentryTest('should not add source context lines to errors from script files', as
88

99
const eventReqPromise = waitForErrorRequestOnUrl(page, url);
1010

11-
const clickPromise = page.click('#script-error-btn');
11+
const clickPromise = page.locator('#script-error-btn').click();
1212

1313
const [req] = await Promise.all([eventReqPromise, clickPromise]);
1414

dev-packages/browser-integration-tests/suites/integrations/ContextLines/scriptTag/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sentryTest(
1919

2020
const eventReqPromise = waitForErrorRequestOnUrl(page, url);
2121

22-
const clickPromise = page.click('#inline-error-btn');
22+
const clickPromise = page.locator('#inline-error-btn').click();
2323

2424
const [req] = await Promise.all([eventReqPromise, clickPromise]);
2525

dev-packages/browser-integration-tests/suites/replay/bufferMode/test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ sentryTest(
4848
const url = await getLocalTestPath({ testDir: __dirname });
4949

5050
await page.goto(url);
51-
await page.click('#go-background');
52-
await page.click('#error');
51+
await page.locator('#go-background').click();
52+
await page.locator('#error').click();
5353
await new Promise(resolve => setTimeout(resolve, 1000));
5454

5555
// error, no replays
@@ -76,9 +76,9 @@ sentryTest(
7676
}),
7777
).toBe(true);
7878

79-
await page.click('#log');
80-
await page.click('#go-background');
81-
await page.click('#error2');
79+
await page.locator('#log').click();
80+
await page.locator('#go-background').click();
81+
await page.locator('#error2').click();
8282
await new Promise(resolve => setTimeout(resolve, 1000));
8383

8484
// 2 errors
@@ -98,8 +98,8 @@ sentryTest(
9898
await reqErrorPromise;
9999
expect(callsToSentry).toBeGreaterThanOrEqual(3);
100100

101-
await page.click('#log');
102-
await page.click('#go-background');
101+
await page.locator('#log').click();
102+
await page.locator('#go-background').click();
103103

104104
// Switches to session mode and then goes to background
105105
const req1 = await reqPromise1;
@@ -193,8 +193,8 @@ sentryTest(
193193
const url = await getLocalTestPath({ testDir: __dirname });
194194

195195
await page.goto(url);
196-
await page.click('#go-background');
197-
await page.click('#error');
196+
await page.locator('#go-background').click();
197+
await page.locator('#error').click();
198198
await new Promise(resolve => setTimeout(resolve, 1000));
199199

200200
// error, no replays
@@ -221,9 +221,9 @@ sentryTest(
221221
}),
222222
).toBe(true);
223223

224-
await page.click('#log');
225-
await page.click('#go-background');
226-
await page.click('#error2');
224+
await page.locator('#log').click();
225+
await page.locator('#go-background').click();
226+
await page.locator('#error2').click();
227227
await new Promise(resolve => setTimeout(resolve, 1000));
228228

229229
// 2 errors
@@ -243,8 +243,8 @@ sentryTest(
243243
await reqErrorPromise;
244244
expect(callsToSentry).toEqual(3);
245245

246-
await page.click('#log');
247-
await page.click('#go-background');
246+
await page.locator('#log').click();
247+
await page.locator('#go-background').click();
248248

249249
// Has stopped recording, should make no more calls to Sentry
250250
expect(callsToSentry).toEqual(3);
@@ -336,8 +336,8 @@ sentryTest(
336336
}),
337337
).toBe(true);
338338

339-
await page.click('#go-background');
340-
await page.click('#error');
339+
await page.locator('#go-background').click();
340+
await page.locator('#error').click();
341341
await new Promise(resolve => setTimeout(resolve, 1000));
342342

343343
// 1 unsampled error, no replay
@@ -357,7 +357,7 @@ sentryTest(
357357
const [req0] = await Promise.all([
358358
// 1 unsampled error, 1 sampled error -> 1 flush
359359
reqPromise0,
360-
page.click('#error2'),
360+
page.locator('#error2').click(),
361361
]);
362362

363363
const reqError1 = await reqErrorPromise1;

dev-packages/browser-integration-tests/suites/replay/bufferModeReload/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sentryTest('continues buffer session in session mode after error & reload', asyn
2828
await page.goto(url);
2929

3030
// buffer session captures an error & switches to session mode
31-
await page.click('#buttonError');
31+
await page.locator('#buttonError').click();
3232
await new Promise(resolve => setTimeout(resolve, 300));
3333
await reqPromise1;
3434

0 commit comments

Comments
 (0)