Skip to content

Commit d5111e1

Browse files
committed
test: Try to fix flaky tests?
1 parent c5f8e48 commit d5111e1

File tree

2 files changed

+30
-23
lines changed
  • packages/browser-integration-tests/suites
    • public-api/startTransaction/basic_usage
    • stacktraces/protocol_fn_identifiers

2 files changed

+30
-23
lines changed
Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
const transaction = Sentry.startTransaction({ name: 'test_transaction_1' });
2-
const span_1 = transaction.startChild({
3-
op: 'span_1',
4-
data: {
5-
foo: 'bar',
6-
baz: [1, 2, 3],
7-
},
8-
});
9-
for (let i = 0; i < 2000; i++);
1+
async function run() {
2+
const transaction = Sentry.startTransaction({ name: 'test_transaction_1' });
3+
const span_1 = transaction.startChild({
4+
op: 'span_1',
5+
data: {
6+
foo: 'bar',
7+
baz: [1, 2, 3],
8+
},
9+
});
1010

11-
// span_1 finishes
12-
span_1.finish();
11+
await new Promise(resolve => setTimeout(resolve, 1));
1312

14-
// span_2 doesn't finish
15-
const span_2 = transaction.startChild({ op: 'span_2' });
16-
for (let i = 0; i < 4000; i++);
13+
// span_1 finishes
14+
span_1.finish();
1715

18-
const span_3 = transaction.startChild({ op: 'span_3' });
19-
for (let i = 0; i < 4000; i++);
16+
// span_2 doesn't finish
17+
const span_2 = transaction.startChild({ op: 'span_2' });
18+
await new Promise(resolve => setTimeout(resolve, 1));
2019

21-
// span_4 is the child of span_3 but doesn't finish.
22-
const span_4 = span_3.startChild({ op: 'span_4', data: { qux: 'quux' } });
20+
const span_3 = transaction.startChild({ op: 'span_3' });
21+
await new Promise(resolve => setTimeout(resolve, 1));
2322

24-
// span_5 is another child of span_3 but finishes.
25-
const span_5 = span_3.startChild({ op: 'span_5' }).finish();
23+
// span_4 is the child of span_3 but doesn't finish.
24+
const span_4 = span_3.startChild({ op: 'span_4', data: { qux: 'quux' } });
2625

27-
// span_3 also finishes
28-
span_3.finish();
26+
// span_5 is another child of span_3 but finishes.
27+
const span_5 = span_3.startChild({ op: 'span_5' }).finish();
2928

30-
transaction.finish();
29+
// span_3 also finishes
30+
span_3.finish();
31+
32+
transaction.finish();
33+
}
34+
35+
run();

packages/browser-integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ sentryTest(
88
'should parse function identifiers that are protocol names correctly',
99
async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => {
1010
const url = await getLocalTestPath({ testDir: __dirname });
11+
await page.goto(url);
1112

1213
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
1314
const frames = eventData.exception?.values?.[0].stacktrace?.frames;
@@ -54,6 +55,7 @@ sentryTest(
5455
'should not add any part of the function identifier to beginning of filename',
5556
async ({ getLocalTestPath, page }) => {
5657
const url = await getLocalTestPath({ testDir: __dirname });
58+
await page.goto(url);
5759

5860
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
5961

0 commit comments

Comments
 (0)