Skip to content

Commit 1f0dc68

Browse files
committed
Switch to Promise.all
1 parent dbe15d6 commit 1f0dc68

File tree

9 files changed

+72
-56
lines changed

9 files changed

+72
-56
lines changed

dev-packages/browser-integration-tests/suites/public-api/instrumentation/onError/non-string-arg/test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ sentryTest(
1111

1212
await page.goto(url);
1313

14-
runScriptInSandbox(page, {
15-
content: `
14+
const [, eventData] = await Promise.all([
15+
runScriptInSandbox(page, {
16+
content: `
1617
throw {
1718
type: 'Error',
1819
otherKey: 'otherValue',
1920
};
2021
`,
21-
});
22-
23-
const eventData = await getFirstSentryEnvelopeRequest<Event>(page);
22+
}),
23+
getFirstSentryEnvelopeRequest<Event>(page),
24+
]);
2425

2526
expect(eventData.exception?.values).toHaveLength(1);
2627
expect(eventData.exception?.values?.[0]).toMatchObject({

dev-packages/browser-integration-tests/suites/public-api/instrumentation/onError/rethrown/test.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ sentryTest(
1111

1212
await page.goto(url);
1313

14-
runScriptInSandbox(page, {
15-
content: `
16-
try {
17-
foo();
18-
} catch (e) {
19-
Sentry.captureException(e);
20-
throw e;
21-
}
22-
`,
23-
});
24-
25-
const events = await getMultipleSentryEnvelopeRequests<Event>(page, 1);
14+
const [, events] = await Promise.all([
15+
runScriptInSandbox(page, {
16+
content: `
17+
try {
18+
foo();
19+
} catch (e) {
20+
Sentry.captureException(e);
21+
throw e;
22+
}
23+
`,
24+
}),
25+
getMultipleSentryEnvelopeRequests<Event>(page, 1),
26+
]);
2627

2728
expect(events[0].exception?.values).toHaveLength(1);
2829
expect(events[0].exception?.values?.[0]).toMatchObject({

dev-packages/browser-integration-tests/suites/public-api/instrumentation/onError/syntax-errors/test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ sentryTest('should catch syntax errors', async ({ getLocalTestPath, page }) => {
99

1010
await page.goto(url);
1111

12-
runScriptInSandbox(page, {
13-
content: `
12+
const [, eventData] = await Promise.all([
13+
runScriptInSandbox(page, {
14+
content: `
1415
foo{}; // SyntaxError
1516
`,
16-
});
17-
18-
const eventData = await getFirstSentryEnvelopeRequest<Event>(page);
17+
}),
18+
getFirstSentryEnvelopeRequest<Event>(page),
19+
]);
1920

2021
expect(eventData.exception?.values).toHaveLength(1);
2122
expect(eventData.exception?.values?.[0]).toMatchObject({

dev-packages/browser-integration-tests/suites/public-api/instrumentation/onError/thrown-errors/test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ sentryTest('should catch thrown errors', async ({ getLocalTestPath, page }) => {
99

1010
await page.goto(url);
1111

12-
runScriptInSandbox(page, {
13-
content: `
12+
const [, eventData] = await Promise.all([
13+
runScriptInSandbox(page, {
14+
content: `
1415
throw new Error('realError');
15-
`,
16-
});
17-
18-
const eventData = await getFirstSentryEnvelopeRequest<Event>(page);
16+
`,
17+
}),
18+
getFirstSentryEnvelopeRequest<Event>(page),
19+
]);
1920

2021
expect(eventData.exception?.values).toHaveLength(1);
2122
expect(eventData.exception?.values?.[0]).toMatchObject({

dev-packages/browser-integration-tests/suites/public-api/instrumentation/onError/thrown-objects/test.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ sentryTest('should catch thrown objects', async ({ getLocalTestPath, page }) =>
99

1010
await page.goto(url);
1111

12-
runScriptInSandbox(page, {
13-
content: `
14-
throw {
15-
error: 'stuff is broken',
16-
somekey: 'ok'
17-
};`,
18-
});
19-
20-
const eventData = await getFirstSentryEnvelopeRequest<Event>(page);
12+
const [, eventData] = await Promise.all([
13+
runScriptInSandbox(page, {
14+
content: `
15+
throw {
16+
error: 'stuff is broken',
17+
somekey: 'ok'
18+
};`,
19+
}),
20+
getFirstSentryEnvelopeRequest<Event>(page),
21+
]);
2122

2223
expect(eventData.exception?.values).toHaveLength(1);
2324
expect(eventData.exception?.values?.[0]).toMatchObject({

dev-packages/browser-integration-tests/suites/public-api/instrumentation/onError/thrown-strings/test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ sentryTest('should catch thrown strings', async ({ getLocalTestPath, page }) =>
99

1010
await page.goto(url);
1111

12-
runScriptInSandbox(page, {
13-
content: `
12+
const [, eventData] = await Promise.all([
13+
runScriptInSandbox(page, {
14+
content: `
1415
throw 'stringError';
1516
`,
16-
});
17-
18-
const eventData = await getFirstSentryEnvelopeRequest<Event>(page);
17+
}),
18+
getFirstSentryEnvelopeRequest<Event>(page),
19+
]);
1920

2021
expect(eventData.exception?.values).toHaveLength(1);
2122
expect(eventData.exception?.values?.[0]).toMatchObject({

dev-packages/browser-integration-tests/suites/public-api/startSpan/error-sync/test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ sentryTest('should capture an error within a sync startSpan callback', async ({
1616
const url = await getLocalTestPath({ testDir: __dirname });
1717
await page.goto(url);
1818

19-
runScriptInSandbox(page, {
20-
content: `
19+
const [, events] = await Promise.all([
20+
runScriptInSandbox(page, {
21+
content: `
2122
function run() {
2223
Sentry.startSpan({ name: 'parent_span' }, () => {
2324
throw new Error('Sync Error');
@@ -26,9 +27,9 @@ sentryTest('should capture an error within a sync startSpan callback', async ({
2627
2728
setTimeout(run);
2829
`,
29-
});
30-
31-
const events = await getMultipleSentryEnvelopeRequests<Event>(page, 2);
30+
}),
31+
getMultipleSentryEnvelopeRequests<Event>(page, 2),
32+
]);
3233

3334
const txn = events.find(event => event.type === 'transaction');
3435
const err = events.find(event => !event.type);

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/error/test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ sentryTest(
1818

1919
await page.goto(url);
2020

21-
runScriptInSandbox(page, {
22-
content: `
23-
throw new Error('Error during pageload');
24-
`,
25-
});
26-
27-
const [e1, e2] = await getMultipleSentryEnvelopeRequests<Event>(page, 2);
21+
const [, [e1, e2]] = await Promise.all([
22+
runScriptInSandbox(page, {
23+
content: `
24+
throw new Error('Error during pageload');
25+
`,
26+
}),
27+
getMultipleSentryEnvelopeRequests<Event>(page, 2),
28+
]);
2829

2930
const pageloadTxnEvent = e1.type === 'transaction' ? e1 : e2;
3031
const errorEvent = e1.type === 'transaction' ? e2 : e1;

dev-packages/browser-integration-tests/utils/helpers.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const countEnvelopes = async (
145145
};
146146

147147
/**
148-
* Run script at the given path inside the test environment.
148+
* Run script inside the test environment.
149149
*
150150
* @param {Page} page
151151
* @param {{ path?: string; content?: string }} impl
@@ -158,7 +158,15 @@ async function runScriptInSandbox(
158158
content?: string;
159159
},
160160
): Promise<void> {
161-
await page.addScriptTag({ path: impl.path, content: impl.content });
161+
try {
162+
await page.addScriptTag({ path: impl.path, content: impl.content });
163+
} catch (e) {
164+
// no-op
165+
}
166+
}
167+
168+
/**
169+
*
162170
}
163171
164172
/**

0 commit comments

Comments
 (0)