-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tests): Update
loader
integration tests to avoid flakes. (#8601)
Playwright's event listeners and `page.goto` functions can occasionally end up in race condition, even when they are invoked in the correct order. The workaround is to invoke them in `Promise.all`, unless there's a specific need to separate them.
- Loading branch information
1 parent
67c3b6a
commit da07542
Showing
13 changed files
with
58 additions
and
61 deletions.
There are no files selected for viewing
8 changes: 3 additions & 5 deletions
8
packages/browser-integration-tests/loader-suites/loader/noOnLoad/captureException/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { envelopeRequestParser, waitForErrorRequest } from '../../../../utils/helpers'; | ||
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; | ||
|
||
sentryTest('captureException works', async ({ getLocalTestUrl, page }) => { | ||
const req = waitForErrorRequest(page); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
await page.goto(url); | ||
const req = await waitForErrorRequestOnUrl(page, url); | ||
|
||
const eventData = envelopeRequestParser(await req); | ||
const eventData = envelopeRequestParser(req); | ||
|
||
expect(eventData.message).toBe('Test exception'); | ||
}); |
8 changes: 3 additions & 5 deletions
8
...ages/browser-integration-tests/loader-suites/loader/noOnLoad/customOnErrorHandler/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { envelopeRequestParser, waitForErrorRequest } from '../../../../utils/helpers'; | ||
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; | ||
|
||
sentryTest('error handler works with a recursive custom error handler', async ({ getLocalTestUrl, page }) => { | ||
const req = waitForErrorRequest(page); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
await page.goto(url); | ||
const req = await waitForErrorRequestOnUrl(page, url); | ||
|
||
const eventData = envelopeRequestParser(await req); | ||
const eventData = envelopeRequestParser(req); | ||
expect(eventData.exception?.values?.length).toBe(1); | ||
expect(eventData.exception?.values?.[0]?.value).toBe('window.doSomethingWrong is not a function'); | ||
}); |
8 changes: 3 additions & 5 deletions
8
packages/browser-integration-tests/loader-suites/loader/noOnLoad/errorHandler/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { envelopeRequestParser,waitForErrorRequest } from '../../../../utils/helpers'; | ||
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; | ||
|
||
sentryTest('error handler works', async ({ getLocalTestUrl, page }) => { | ||
const req = waitForErrorRequest(page); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
await page.goto(url); | ||
const req = await waitForErrorRequestOnUrl(page, url); | ||
|
||
const eventData = envelopeRequestParser(await req); | ||
const eventData = envelopeRequestParser(req); | ||
expect(eventData.exception?.values?.length).toBe(1); | ||
expect(eventData.exception?.values?.[0]?.value).toBe('window.doSomethingWrong is not a function'); | ||
}); |
8 changes: 3 additions & 5 deletions
8
packages/browser-integration-tests/loader-suites/loader/noOnLoad/errorHandlerLater/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
packages/browser-integration-tests/loader-suites/loader/noOnLoad/pageloadTransaction/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
packages/browser-integration-tests/loader-suites/loader/onLoad/captureException/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { envelopeRequestParser, waitForErrorRequest } from '../../../../utils/helpers'; | ||
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; | ||
|
||
sentryTest('captureException works', async ({ getLocalTestUrl, page }) => { | ||
const req = waitForErrorRequest(page); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
await page.goto(url); | ||
const req = await waitForErrorRequestOnUrl(page, url); | ||
|
||
const eventData = envelopeRequestParser(await req); | ||
const eventData = envelopeRequestParser(req); | ||
|
||
expect(eventData.message).toBe('Test exception'); | ||
}); |
8 changes: 3 additions & 5 deletions
8
...es/browser-integration-tests/loader-suites/loader/onLoad/captureExceptionInOnLoad/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { envelopeRequestParser, waitForErrorRequest } from '../../../../utils/helpers'; | ||
import { envelopeRequestParser, waitForErrorRequestOnUrl } from '../../../../utils/helpers'; | ||
|
||
sentryTest('captureException works inside of onLoad', async ({ getLocalTestUrl, page }) => { | ||
const req = waitForErrorRequest(page); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
await page.goto(url); | ||
const req = await waitForErrorRequestOnUrl(page, url); | ||
|
||
const eventData = envelopeRequestParser(await req); | ||
const eventData = envelopeRequestParser(req); | ||
|
||
expect(eventData.message).toBe('Test exception'); | ||
}); |
12 changes: 7 additions & 5 deletions
12
packages/browser-integration-tests/loader-suites/loader/onLoad/customBrowserTracing/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
packages/browser-integration-tests/loader-suites/loader/onLoad/errorHandler/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
packages/browser-integration-tests/loader-suites/loader/onLoad/errorHandlerLater/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
packages/browser-integration-tests/loader-suites/loader/onLoad/pageloadTransaction/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters