Skip to content

Commit a2bd1e0

Browse files
authored
test: Try to fix flaky tests? (#7597)
1 parent e1af1e6 commit a2bd1e0

File tree

2 files changed

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

2 files changed

+35
-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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ sentryTest(
1212
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
1313
const frames = eventData.exception?.values?.[0].stacktrace?.frames;
1414

15+
expect(eventData).toBeDefined();
16+
expect(eventData.exception?.values).toBeDefined();
17+
expect(frames).toBeDefined();
18+
1519
runInChromium(() => {
1620
expect(frames).toMatchObject([
1721
{ function: '?' },
@@ -57,6 +61,9 @@ sentryTest(
5761

5862
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
5963

64+
expect(eventData).toBeDefined();
65+
expect(eventData.exception?.values).toBeDefined();
66+
expect(eventData.exception?.values?.[0].stacktrace).toBeDefined();
6067
expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject(
6168
Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }),
6269
);

0 commit comments

Comments
 (0)