Skip to content

Commit e52faa4

Browse files
authored
ref(tests): Simplify integration-test helpers. (#4385)
1 parent 33aef95 commit e52faa4

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

packages/integration-tests/utils/helpers.ts

+2-25
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ const envelopeRequestParser = (request: Request | null): Event => {
1313
return envelope.split('\n').map(line => JSON.parse(line))[2];
1414
};
1515

16-
type SentryRequestType = 'event' | 'transaction';
17-
1816
/**
1917
* Run script at the given path inside the test environment.
2018
*
@@ -26,16 +24,6 @@ async function runScriptInSandbox(page: Page, path: string): Promise<void> {
2624
await page.addScriptTag({ path });
2725
}
2826

29-
/**
30-
* Wait and get Sentry's request sending the event.
31-
*
32-
* @param {Page} page
33-
* @returns {*} {Promise<Request>}
34-
*/
35-
async function waitForSentryRequest(page: Page, requestType: SentryRequestType = 'event'): Promise<Request> {
36-
return page.waitForRequest(requestType === 'event' ? storeUrlRegex : envelopeUrlRegex);
37-
}
38-
3927
/**
4028
* Wait and get Sentry's request sending the event at the given URL, or the current page
4129
*
@@ -44,9 +32,7 @@ async function waitForSentryRequest(page: Page, requestType: SentryRequestType =
4432
* @return {*} {Promise<Event>}
4533
*/
4634
async function getSentryRequest(page: Page, url?: string): Promise<Event> {
47-
const request = (await Promise.all([url ? page.goto(url) : Promise.resolve(null), waitForSentryRequest(page)]))[1];
48-
49-
return storeRequestParser(request);
35+
return (await getMultipleSentryRequests(page, 1, url))[0];
5036
}
5137

5238
/**
@@ -57,15 +43,7 @@ async function getSentryRequest(page: Page, url?: string): Promise<Event> {
5743
* @return {*} {Promise<Event>}
5844
*/
5945
async function getSentryTransactionRequest(page: Page, url?: string): Promise<Event> {
60-
const request = (
61-
await Promise.all([url ? page.goto(url) : Promise.resolve(null), waitForSentryRequest(page, 'transaction')])
62-
)[1];
63-
64-
try {
65-
return envelopeRequestParser(request);
66-
} catch (err) {
67-
return Promise.reject(err);
68-
}
46+
return (await getMultipleSentryTransactionRequests(page, 1, url))[0];
6947
}
7048

7149
/**
@@ -170,7 +148,6 @@ async function injectScriptAndGetEvents(page: Page, url: string, scriptPath: str
170148

171149
export {
172150
runScriptInSandbox,
173-
waitForSentryRequest,
174151
getMultipleSentryRequests,
175152
getMultipleSentryTransactionRequests,
176153
getSentryRequest,

0 commit comments

Comments
 (0)