Skip to content

Commit 5f4a71c

Browse files
author
Luca Forstner
authored
test(e2e): Unflake NestJS e2e tests (#13188)
1 parent 7ad5054 commit 5f4a71c

File tree

23 files changed

+102
-71
lines changed

23 files changed

+102
-71
lines changed

dev-packages/e2e-tests/test-applications/nestjs-basic/src/instrument.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ Sentry.init({
55
dsn: process.env.E2E_TEST_DSN,
66
tunnel: `http://localhost:3031/`, // proxy server
77
tracesSampleRate: 1,
8+
transportOptions: {
9+
// We expect the app to send a lot of events in a short time
10+
bufferSize: 1000,
11+
},
812
});

dev-packages/e2e-tests/test-applications/nestjs-basic/start-event-proxy.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { startEventProxyServer } from '@sentry-internal/test-utils';
22

33
startEventProxyServer({
44
port: 3031,
5-
proxyServerName: 'nestjs',
5+
proxyServerName: 'nestjs-basic',
66
});

dev-packages/e2e-tests/test-applications/nestjs-basic/tests/cron-decorator.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { expect, test } from '@playwright/test';
22
import { waitForEnvelopeItem } from '@sentry-internal/test-utils';
33

44
test('Cron job triggers send of in_progress envelope', async ({ baseURL }) => {
5-
const inProgressEnvelopePromise = waitForEnvelopeItem('nestjs', envelope => {
5+
const inProgressEnvelopePromise = waitForEnvelopeItem('nestjs-basic', envelope => {
66
return envelope[0].type === 'check_in' && envelope[1]['status'] === 'in_progress';
77
});
88

9-
const okEnvelopePromise = waitForEnvelopeItem('nestjs', envelope => {
9+
const okEnvelopePromise = waitForEnvelopeItem('nestjs-basic', envelope => {
1010
return envelope[0].type === 'check_in' && envelope[1]['status'] === 'ok';
1111
});
1212

dev-packages/e2e-tests/test-applications/nestjs-basic/tests/errors.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
22
import { waitForError, waitForTransaction } from '@sentry-internal/test-utils';
33

44
test('Sends exception to Sentry', async ({ baseURL }) => {
5-
const errorEventPromise = waitForError('nestjs', event => {
5+
const errorEventPromise = waitForError('nestjs-basic', event => {
66
return !event.type && event.exception?.values?.[0]?.value === 'This is an exception with id 123';
77
});
88

@@ -32,27 +32,27 @@ test('Sends exception to Sentry', async ({ baseURL }) => {
3232
test('Does not send HttpExceptions to Sentry', async ({ baseURL }) => {
3333
let errorEventOccurred = false;
3434

35-
waitForError('nestjs', event => {
35+
waitForError('nestjs-basic', event => {
3636
if (!event.type && event.exception?.values?.[0]?.value === 'This is an expected 400 exception with id 123') {
3737
errorEventOccurred = true;
3838
}
3939

4040
return event?.transaction === 'GET /test-expected-400-exception/:id';
4141
});
4242

43-
waitForError('nestjs', event => {
43+
waitForError('nestjs-basic', event => {
4444
if (!event.type && event.exception?.values?.[0]?.value === 'This is an expected 500 exception with id 123') {
4545
errorEventOccurred = true;
4646
}
4747

4848
return event?.transaction === 'GET /test-expected-500-exception/:id';
4949
});
5050

51-
const transactionEventPromise400 = waitForTransaction('nestjs', transactionEvent => {
51+
const transactionEventPromise400 = waitForTransaction('nestjs-basic', transactionEvent => {
5252
return transactionEvent?.transaction === 'GET /test-expected-400-exception/:id';
5353
});
5454

55-
const transactionEventPromise500 = waitForTransaction('nestjs', transactionEvent => {
55+
const transactionEventPromise500 = waitForTransaction('nestjs-basic', transactionEvent => {
5656
return transactionEvent?.transaction === 'GET /test-expected-500-exception/:id';
5757
});
5858

dev-packages/e2e-tests/test-applications/nestjs-basic/tests/span-decorator.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
22
import { waitForTransaction } from '@sentry-internal/test-utils';
33

44
test('Transaction includes span and correct value for decorated async function', async ({ baseURL }) => {
5-
const transactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
5+
const transactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {
66
return (
77
transactionEvent?.contexts?.trace?.op === 'http.server' &&
88
transactionEvent?.transaction === 'GET /test-span-decorator-async'
@@ -37,7 +37,7 @@ test('Transaction includes span and correct value for decorated async function',
3737
});
3838

3939
test('Transaction includes span and correct value for decorated sync function', async ({ baseURL }) => {
40-
const transactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
40+
const transactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {
4141
return (
4242
transactionEvent?.contexts?.trace?.op === 'http.server' &&
4343
transactionEvent?.transaction === 'GET /test-span-decorator-sync'

dev-packages/e2e-tests/test-applications/nestjs-basic/tests/transactions.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
22
import { waitForTransaction } from '@sentry-internal/test-utils';
33

44
test('Sends an API route transaction', async ({ baseURL }) => {
5-
const pageloadTransactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
5+
const pageloadTransactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {
66
return (
77
transactionEvent?.contexts?.trace?.op === 'http.server' &&
88
transactionEvent?.transaction === 'GET /test-transaction'
@@ -125,7 +125,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
125125
test('API route transaction includes nest middleware span. Spans created in and after middleware are nested correctly', async ({
126126
baseURL,
127127
}) => {
128-
const pageloadTransactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
128+
const pageloadTransactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {
129129
return (
130130
transactionEvent?.contexts?.trace?.op === 'http.server' &&
131131
transactionEvent?.transaction === 'GET /test-middleware-instrumentation'
@@ -205,7 +205,7 @@ test('API route transaction includes nest middleware span. Spans created in and
205205
test('API route transaction includes nest guard span and span started in guard is nested correctly', async ({
206206
baseURL,
207207
}) => {
208-
const transactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
208+
const transactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {
209209
return (
210210
transactionEvent?.contexts?.trace?.op === 'http.server' &&
211211
transactionEvent?.transaction === 'GET /test-guard-instrumentation'
@@ -268,10 +268,11 @@ test('API route transaction includes nest guard span and span started in guard i
268268
});
269269

270270
test('API route transaction includes nest pipe span for valid request', async ({ baseURL }) => {
271-
const transactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
271+
const transactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {
272272
return (
273273
transactionEvent?.contexts?.trace?.op === 'http.server' &&
274-
transactionEvent?.transaction === 'GET /test-pipe-instrumentation/:id'
274+
transactionEvent?.transaction === 'GET /test-pipe-instrumentation/:id' &&
275+
transactionEvent?.request?.url?.includes('/test-pipe-instrumentation/123')
275276
);
276277
});
277278

@@ -304,10 +305,11 @@ test('API route transaction includes nest pipe span for valid request', async ({
304305
});
305306

306307
test('API route transaction includes nest pipe span for invalid request', async ({ baseURL }) => {
307-
const transactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
308+
const transactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {
308309
return (
309310
transactionEvent?.contexts?.trace?.op === 'http.server' &&
310-
transactionEvent?.transaction === 'GET /test-pipe-instrumentation/:id'
311+
transactionEvent?.transaction === 'GET /test-pipe-instrumentation/:id' &&
312+
transactionEvent?.request?.url?.includes('/test-pipe-instrumentation/abc')
311313
);
312314
});
313315

@@ -342,7 +344,7 @@ test('API route transaction includes nest pipe span for invalid request', async
342344
test('API route transaction includes nest interceptor span. Spans created in and after interceptor are nested correctly', async ({
343345
baseURL,
344346
}) => {
345-
const pageloadTransactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
347+
const pageloadTransactionEventPromise = waitForTransaction('nestjs-basic', transactionEvent => {
346348
return (
347349
transactionEvent?.contexts?.trace?.op === 'http.server' &&
348350
transactionEvent?.transaction === 'GET /test-interceptor-instrumentation'

dev-packages/e2e-tests/test-applications/nestjs-distributed-tracing/src/instrument.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ Sentry.init({
66
tunnel: `http://localhost:3031/`, // proxy server
77
tracesSampleRate: 1,
88
tracePropagationTargets: ['http://localhost:3030', '/external-allowed'],
9+
transportOptions: {
10+
// We expect the app to send a lot of events in a short time
11+
bufferSize: 1000,
12+
},
913
});

dev-packages/e2e-tests/test-applications/nestjs-distributed-tracing/start-event-proxy.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { startEventProxyServer } from '@sentry-internal/test-utils';
22

33
startEventProxyServer({
44
port: 3031,
5-
proxyServerName: 'nestjs',
5+
proxyServerName: 'nestjs-distributed-tracing',
66
});

dev-packages/e2e-tests/test-applications/nestjs-distributed-tracing/tests/propagation.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { SpanJSON } from '@sentry/types';
66
test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
77
const id = crypto.randomUUID();
88

9-
const inboundTransactionPromise = waitForTransaction('nestjs', transactionEvent => {
9+
const inboundTransactionPromise = waitForTransaction('nestjs-distributed-tracing', transactionEvent => {
1010
return (
1111
transactionEvent.contexts?.trace?.op === 'http.server' &&
1212
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-inbound-headers/${id}`
1313
);
1414
});
1515

16-
const outboundTransactionPromise = waitForTransaction('nestjs', transactionEvent => {
16+
const outboundTransactionPromise = waitForTransaction('nestjs-distributed-tracing', transactionEvent => {
1717
return (
1818
transactionEvent.contexts?.trace?.op === 'http.server' &&
1919
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-http/${id}`
@@ -66,7 +66,7 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
6666
'http.method': 'GET',
6767
'http.scheme': 'http',
6868
'http.target': `/test-outgoing-http/${id}`,
69-
'http.user_agent': 'node',
69+
'http.user_agent': expect.any(String),
7070
'http.flavor': '1.1',
7171
'net.transport': 'ip_tcp',
7272
'net.host.ip': expect.any(String),
@@ -121,14 +121,14 @@ test('Propagates trace for outgoing http requests', async ({ baseURL }) => {
121121
test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
122122
const id = crypto.randomUUID();
123123

124-
const inboundTransactionPromise = waitForTransaction('nestjs', transactionEvent => {
124+
const inboundTransactionPromise = waitForTransaction('nestjs-distributed-tracing', transactionEvent => {
125125
return (
126126
transactionEvent?.contexts?.trace?.op === 'http.server' &&
127127
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-inbound-headers/${id}`
128128
);
129129
});
130130

131-
const outboundTransactionPromise = waitForTransaction('nestjs', transactionEvent => {
131+
const outboundTransactionPromise = waitForTransaction('nestjs-distributed-tracing', transactionEvent => {
132132
return (
133133
transactionEvent?.contexts?.trace?.op === 'http.server' &&
134134
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-fetch/${id}`
@@ -181,7 +181,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
181181
'http.method': 'GET',
182182
'http.scheme': 'http',
183183
'http.target': `/test-outgoing-fetch/${id}`,
184-
'http.user_agent': 'node',
184+
'http.user_agent': expect.any(String),
185185
'http.flavor': '1.1',
186186
'net.transport': 'ip_tcp',
187187
'net.host.ip': expect.any(String),
@@ -234,7 +234,7 @@ test('Propagates trace for outgoing fetch requests', async ({ baseURL }) => {
234234
});
235235

236236
test('Propagates trace for outgoing external http requests', async ({ baseURL }) => {
237-
const inboundTransactionPromise = waitForTransaction('nestjs', transactionEvent => {
237+
const inboundTransactionPromise = waitForTransaction('nestjs-distributed-tracing', transactionEvent => {
238238
return (
239239
transactionEvent?.contexts?.trace?.op === 'http.server' &&
240240
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-http-external-allowed`
@@ -271,7 +271,7 @@ test('Propagates trace for outgoing external http requests', async ({ baseURL })
271271
});
272272

273273
test('Does not propagate outgoing http requests not covered by tracePropagationTargets', async ({ baseURL }) => {
274-
const inboundTransactionPromise = waitForTransaction('nestjs', transactionEvent => {
274+
const inboundTransactionPromise = waitForTransaction('nestjs-distributed-tracing', transactionEvent => {
275275
return (
276276
transactionEvent?.contexts?.trace?.op === 'http.server' &&
277277
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-http-external-disallowed`
@@ -295,7 +295,7 @@ test('Does not propagate outgoing http requests not covered by tracePropagationT
295295
});
296296

297297
test('Propagates trace for outgoing external fetch requests', async ({ baseURL }) => {
298-
const inboundTransactionPromise = waitForTransaction('nestjs', transactionEvent => {
298+
const inboundTransactionPromise = waitForTransaction('nestjs-distributed-tracing', transactionEvent => {
299299
return (
300300
transactionEvent?.contexts?.trace?.op === 'http.server' &&
301301
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-fetch-external-allowed`
@@ -332,7 +332,7 @@ test('Propagates trace for outgoing external fetch requests', async ({ baseURL }
332332
});
333333

334334
test('Does not propagate outgoing fetch requests not covered by tracePropagationTargets', async ({ baseURL }) => {
335-
const inboundTransactionPromise = waitForTransaction('nestjs', transactionEvent => {
335+
const inboundTransactionPromise = waitForTransaction('nestjs-distributed-tracing', transactionEvent => {
336336
return (
337337
transactionEvent?.contexts?.trace?.op === 'http.server' &&
338338
transactionEvent.contexts?.trace?.data?.['http.target'] === `/test-outgoing-fetch-external-disallowed`

dev-packages/e2e-tests/test-applications/nestjs-with-submodules/src/instrument.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ Sentry.init({
55
dsn: process.env.E2E_TEST_DSN,
66
tunnel: `http://localhost:3031/`, // proxy server
77
tracesSampleRate: 1,
8+
transportOptions: {
9+
// We expect the app to send a lot of events in a short time
10+
bufferSize: 1000,
11+
},
812
});

dev-packages/e2e-tests/test-applications/nestjs-with-submodules/start-event-proxy.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { startEventProxyServer } from '@sentry-internal/test-utils';
22

33
startEventProxyServer({
44
port: 3031,
5-
proxyServerName: 'nestjs',
5+
proxyServerName: 'nestjs-with-submodules',
66
});

dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/errors.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
22
import { waitForError, waitForTransaction } from '@sentry-internal/test-utils';
33

44
test('Sends unexpected exception to Sentry if thrown in module with global filter', async ({ baseURL }) => {
5-
const errorEventPromise = waitForError('nestjs', event => {
5+
const errorEventPromise = waitForError('nestjs-with-submodules', event => {
66
return !event.type && event.exception?.values?.[0]?.value === 'This is an uncaught exception!';
77
});
88

@@ -32,7 +32,7 @@ test('Sends unexpected exception to Sentry if thrown in module with global filte
3232
test('Sends unexpected exception to Sentry if thrown in module that was registered before Sentry', async ({
3333
baseURL,
3434
}) => {
35-
const errorEventPromise = waitForError('nestjs', event => {
35+
const errorEventPromise = waitForError('nestjs-with-submodules', event => {
3636
return !event.type && event.exception?.values?.[0]?.value === 'This is an uncaught exception!';
3737
});
3838

@@ -64,15 +64,15 @@ test('Does not send exception to Sentry if user-defined global exception filter
6464
}) => {
6565
let errorEventOccurred = false;
6666

67-
waitForError('nestjs', event => {
67+
waitForError('nestjs-with-submodules', event => {
6868
if (!event.type && event.exception?.values?.[0]?.value === 'Something went wrong in the example module!') {
6969
errorEventOccurred = true;
7070
}
7171

7272
return event?.transaction === 'GET /example-module/expected-exception';
7373
});
7474

75-
const transactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
75+
const transactionEventPromise = waitForTransaction('nestjs-with-submodules', transactionEvent => {
7676
return transactionEvent?.transaction === 'GET /example-module/expected-exception';
7777
});
7878

@@ -91,7 +91,7 @@ test('Does not send exception to Sentry if user-defined local exception filter a
9191
}) => {
9292
let errorEventOccurred = false;
9393

94-
waitForError('nestjs', event => {
94+
waitForError('nestjs-with-submodules', event => {
9595
if (
9696
!event.type &&
9797
event.exception?.values?.[0]?.value === 'Something went wrong in the example module with local filter!'
@@ -102,7 +102,7 @@ test('Does not send exception to Sentry if user-defined local exception filter a
102102
return event?.transaction === 'GET /example-module-local-filter/expected-exception';
103103
});
104104

105-
const transactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
105+
const transactionEventPromise = waitForTransaction('nestjs-with-submodules', transactionEvent => {
106106
return transactionEvent?.transaction === 'GET /example-module-local-filter/expected-exception';
107107
});
108108

@@ -119,7 +119,7 @@ test('Does not send exception to Sentry if user-defined local exception filter a
119119
test('Does not handle expected exception if exception is thrown in module registered before Sentry', async ({
120120
baseURL,
121121
}) => {
122-
const errorEventPromise = waitForError('nestjs', event => {
122+
const errorEventPromise = waitForError('nestjs-with-submodules', event => {
123123
return !event.type && event.exception?.values?.[0]?.value === 'Something went wrong in the example module!';
124124
});
125125

dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/transactions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
22
import { waitForTransaction } from '@sentry-internal/test-utils';
33

44
test('Sends an API route transaction from module', async ({ baseURL }) => {
5-
const pageloadTransactionEventPromise = waitForTransaction('nestjs', transactionEvent => {
5+
const pageloadTransactionEventPromise = waitForTransaction('nestjs-with-submodules', transactionEvent => {
66
return (
77
transactionEvent?.contexts?.trace?.op === 'http.server' &&
88
transactionEvent?.transaction === 'GET /example-module/transaction'

dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/instrument.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ Sentry.init({
55
dsn: process.env.E2E_TEST_DSN,
66
tunnel: `http://localhost:3031/`, // proxy server
77
tracesSampleRate: 1,
8+
transportOptions: {
9+
// We expect the app to send a lot of events in a short time
10+
bufferSize: 1000,
11+
},
812
});

dev-packages/e2e-tests/test-applications/node-nestjs-basic/start-event-proxy.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { startEventProxyServer } from '@sentry-internal/test-utils';
22

33
startEventProxyServer({
44
port: 3031,
5-
proxyServerName: 'nestjs',
5+
proxyServerName: 'node-nestjs-basic',
66
});

dev-packages/e2e-tests/test-applications/node-nestjs-basic/tests/cron-decorator.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { expect, test } from '@playwright/test';
22
import { waitForEnvelopeItem } from '@sentry-internal/test-utils';
33

44
test('Cron job triggers send of in_progress envelope', async ({ baseURL }) => {
5-
const inProgressEnvelopePromise = waitForEnvelopeItem('nestjs', envelope => {
5+
const inProgressEnvelopePromise = waitForEnvelopeItem('node-nestjs-basic', envelope => {
66
return envelope[0].type === 'check_in' && envelope[1]['status'] === 'in_progress';
77
});
88

9-
const okEnvelopePromise = waitForEnvelopeItem('nestjs', envelope => {
9+
const okEnvelopePromise = waitForEnvelopeItem('node-nestjs-basic', envelope => {
1010
return envelope[0].type === 'check_in' && envelope[1]['status'] === 'ok';
1111
});
1212

0 commit comments

Comments
 (0)