Skip to content

Commit 23980a0

Browse files
authored
test: Ensure browser-integration-tests cannot conflict due to build (#13338)
This streamlines some stuff in our browser integration tests, to fix some flakiness (hopefully). The biggest change is that instead of always building into `dist` for each test file, each test will now build into a random subfolder, e.g. `dist/abc`. This way, multiple tests in a single file will never conflict with each other. Additionally it also streamlines some of the tests I encountered while looking at stuff, hopefully reducing flakes further. Closes #13321
1 parent 0af5b4f commit 23980a0

File tree

59 files changed

+516
-620
lines changed

Some content is hidden

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

59 files changed

+516
-620
lines changed

dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/sdkLoadedInMeanwhile/test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fs from 'fs';
2-
import path from 'path';
1+
import * as fs from 'fs';
2+
import * as path from 'path';
33
import { expect } from '@playwright/test';
44

55
import { TEST_HOST, sentryTest } from '../../../../utils/fixtures';
@@ -28,19 +28,22 @@ sentryTest('it does not download the SDK if the SDK was loaded in the meanwhile'
2828
});
2929
});
3030

31+
const tmpDir = await getLocalTestUrl({ testDir: __dirname, skipRouteHandler: true });
32+
3133
await page.route(`${TEST_HOST}/*.*`, route => {
3234
const file = route.request().url().split('/').pop();
3335

3436
if (file === 'cdn.bundle.js') {
3537
cdnLoadedCount++;
3638
}
3739

38-
const filePath = path.resolve(__dirname, `./dist/${file}`);
40+
const filePath = path.resolve(tmpDir, `./${file}`);
3941

4042
return fs.existsSync(filePath) ? route.fulfill({ path: filePath }) : route.continue();
4143
});
4244

43-
const url = await getLocalTestUrl({ testDir: __dirname, skipRouteHandler: true });
45+
const url = `${TEST_HOST}/index.html`;
46+
4447
const req = await waitForErrorRequestOnUrl(page, url);
4548

4649
const eventData = envelopeRequestParser(req);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const config: PlaywrightTestConfig = {
3131
],
3232

3333
globalSetup: require.resolve('./playwright.setup.ts'),
34+
globalTeardown: require.resolve('./playwright.teardown.ts'),
3435
};
3536

3637
export default config;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as childProcess from 'child_process';
2+
3+
export default function globalTeardown(): void {
4+
childProcess.execSync('yarn clean', { stdio: 'inherit', cwd: process.cwd() });
5+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
fetch('http://localhost:7654/foo').then(() => {
1+
fetch('http://sentry-test.io/foo').then(() => {
22
Sentry.captureException('test error');
33
});

dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/get/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sentryTest('captures Breadcrumb for basic GET request', async ({ getLocalTestUrl
3131
data: {
3232
method: 'GET',
3333
status_code: 200,
34-
url: 'http://localhost:7654/foo',
34+
url: 'http://sentry-test.io/foo',
3535
},
3636
});
3737
});
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
fetch(new Request('http://localhost:7654/foo')).then(() => {
1+
fetch(new Request('http://sentry-test.io/foo')).then(() => {
22
Sentry.captureException('test error');
33
});

dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/getWithRequestObj/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sentryTest('captures Breadcrumb for basic GET request that uses request object',
3131
data: {
3232
method: 'GET',
3333
status_code: 200,
34-
url: 'http://localhost:7654/foo',
34+
url: 'http://sentry-test.io/foo',
3535
},
3636
});
3737
});

dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/subject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fetch('http://localhost:7654/foo', {
1+
fetch('http://sentry-test.io/foo', {
22
method: 'POST',
33
body: '{"my":"body"}',
44
headers: {

dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/fetch/post/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sentryTest('captures Breadcrumb for POST request', async ({ getLocalTestUrl, pag
3131
data: {
3232
method: 'POST',
3333
status_code: 200,
34-
url: 'http://localhost:7654/foo',
34+
url: 'http://sentry-test.io/foo',
3535
},
3636
});
3737
});

dev-packages/browser-integration-tests/suites/integrations/Breadcrumbs/xhr/get/subject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const xhr = new XMLHttpRequest();
22

3-
xhr.open('GET', 'http://localhost:7654/foo');
3+
xhr.open('GET', 'http://sentry-test.io/foo');
44
xhr.send();
55

66
xhr.addEventListener('readystatechange', function () {

0 commit comments

Comments
 (0)