From 8fc0c01d3a4d6c1b6097092d5f303dbc380405c8 Mon Sep 17 00:00:00 2001 From: nicohrubec Date: Tue, 6 Aug 2024 09:07:30 +0200 Subject: [PATCH 1/3] tests go brr --- .../test-applications/nestjs-basic/src/app.controller.ts | 6 ++++++ .../test-applications/nestjs-basic/tests/errors.test.ts | 4 ++-- .../nestjs-with-submodules/src/app.controller.ts | 6 ++++++ .../nestjs-with-submodules/tests/errors.test.ts | 2 +- .../node-nestjs-basic/src/app.controller.ts | 6 ++++++ .../node-nestjs-basic/tests/errors.test.ts | 4 ++-- 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/nestjs-basic/src/app.controller.ts b/dev-packages/e2e-tests/test-applications/nestjs-basic/src/app.controller.ts index 5becddbc05e0..add46e71a399 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-basic/src/app.controller.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-basic/src/app.controller.ts @@ -1,4 +1,5 @@ import { Controller, Get, Param, ParseIntPipe, UseGuards, UseInterceptors } from '@nestjs/common'; +import { flush } from '@sentry/nestjs'; import { AppService } from './app.service'; import { ExampleGuard } from './example.guard'; import { ExampleInterceptor } from './example.interceptor'; @@ -68,4 +69,9 @@ export class AppController { async killTestCron() { this.appService.killTestCron(); } + + @Get('flush') + async flush() { + flush(); + } } diff --git a/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/errors.test.ts index ccc919cdd025..e2b1555c2b35 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/errors.test.ts @@ -65,7 +65,7 @@ test('Does not send HttpExceptions to Sentry', async ({ baseURL }) => { await transactionEventPromise400; await transactionEventPromise500; - await new Promise(resolve => setTimeout(resolve, 10000)); + await fetch(`${baseURL}/flush`); expect(errorEventOccurred).toBe(false); }); @@ -90,7 +90,7 @@ test('Does not send RpcExceptions to Sentry', async ({ baseURL }) => { await transactionEventPromise; - await new Promise(resolve => setTimeout(resolve, 10000)); + await fetch(`${baseURL}/flush`); expect(errorEventOccurred).toBe(false); }); diff --git a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/src/app.controller.ts b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/src/app.controller.ts index 71a410e8d0a8..5ad508683575 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/src/app.controller.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/src/app.controller.ts @@ -1,4 +1,5 @@ import { Controller, Get, Param } from '@nestjs/common'; +import { flush } from '@sentry/nestjs'; import { AppService } from './app.service'; @Controller() @@ -14,4 +15,9 @@ export class AppController { async testExpectedException(@Param('id') id: string) { return this.appService.testExpectedException(id); } + + @Get('flush') + async flush() { + flush(); + } } diff --git a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/errors.test.ts index 87b828dc8501..72ffcf6d8fe9 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/errors.test.ts @@ -111,7 +111,7 @@ test('Does not send exception to Sentry if user-defined local exception filter a await transactionEventPromise; - await new Promise(resolve => setTimeout(resolve, 10000)); + await fetch(`${baseURL}/flush`); expect(errorEventOccurred).toBe(false); }); diff --git a/dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/app.controller.ts b/dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/app.controller.ts index 5becddbc05e0..add46e71a399 100644 --- a/dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/app.controller.ts +++ b/dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/app.controller.ts @@ -1,4 +1,5 @@ import { Controller, Get, Param, ParseIntPipe, UseGuards, UseInterceptors } from '@nestjs/common'; +import { flush } from '@sentry/nestjs'; import { AppService } from './app.service'; import { ExampleGuard } from './example.guard'; import { ExampleInterceptor } from './example.interceptor'; @@ -68,4 +69,9 @@ export class AppController { async killTestCron() { this.appService.killTestCron(); } + + @Get('flush') + async flush() { + flush(); + } } diff --git a/dev-packages/e2e-tests/test-applications/node-nestjs-basic/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/node-nestjs-basic/tests/errors.test.ts index 171f42920487..063dc9dedeee 100644 --- a/dev-packages/e2e-tests/test-applications/node-nestjs-basic/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-nestjs-basic/tests/errors.test.ts @@ -65,7 +65,7 @@ test('Does not send HttpExceptions to Sentry', async ({ baseURL }) => { await transactionEventPromise400; await transactionEventPromise500; - await new Promise(resolve => setTimeout(resolve, 10000)); + await fetch(`${baseURL}/flush`); expect(errorEventOccurred).toBe(false); }); @@ -90,7 +90,7 @@ test('Does not send RpcExceptions to Sentry', async ({ baseURL }) => { await transactionEventPromise; - await new Promise(resolve => setTimeout(resolve, 10000)); + await fetch(`${baseURL}/flush`); expect(errorEventOccurred).toBe(false); }); From cb6850c517a6cf1c26f376644fda640897159404 Mon Sep 17 00:00:00 2001 From: nicohrubec Date: Tue, 6 Aug 2024 09:32:10 +0200 Subject: [PATCH 2/3] pr review --- .../test-applications/nestjs-basic/src/app.controller.ts | 2 +- .../nestjs-with-submodules/src/app.controller.ts | 2 +- .../nestjs-with-submodules/tests/errors.test.ts | 4 ++-- .../test-applications/node-nestjs-basic/src/app.controller.ts | 2 +- .../test-applications/node-nestjs-basic/tests/errors.test.ts | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/nestjs-basic/src/app.controller.ts b/dev-packages/e2e-tests/test-applications/nestjs-basic/src/app.controller.ts index add46e71a399..ec0a921da2c4 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-basic/src/app.controller.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-basic/src/app.controller.ts @@ -72,6 +72,6 @@ export class AppController { @Get('flush') async flush() { - flush(); + await flush(); } } diff --git a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/src/app.controller.ts b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/src/app.controller.ts index 5ad508683575..0d2c46e90da2 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/src/app.controller.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/src/app.controller.ts @@ -18,6 +18,6 @@ export class AppController { @Get('flush') async flush() { - flush(); + await flush(); } } diff --git a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/errors.test.ts index 72ffcf6d8fe9..6fbc9f2c1f32 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-with-submodules/tests/errors.test.ts @@ -81,7 +81,7 @@ test('Does not send exception to Sentry if user-defined global exception filter await transactionEventPromise; - await new Promise(resolve => setTimeout(resolve, 10000)); + (await fetch(`${baseURL}/flush`)).text(); expect(errorEventOccurred).toBe(false); }); @@ -111,7 +111,7 @@ test('Does not send exception to Sentry if user-defined local exception filter a await transactionEventPromise; - await fetch(`${baseURL}/flush`); + (await fetch(`${baseURL}/flush`)).text(); expect(errorEventOccurred).toBe(false); }); diff --git a/dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/app.controller.ts b/dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/app.controller.ts index add46e71a399..ec0a921da2c4 100644 --- a/dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/app.controller.ts +++ b/dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/app.controller.ts @@ -72,6 +72,6 @@ export class AppController { @Get('flush') async flush() { - flush(); + await flush(); } } diff --git a/dev-packages/e2e-tests/test-applications/node-nestjs-basic/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/node-nestjs-basic/tests/errors.test.ts index 063dc9dedeee..0155c3887805 100644 --- a/dev-packages/e2e-tests/test-applications/node-nestjs-basic/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/node-nestjs-basic/tests/errors.test.ts @@ -65,7 +65,7 @@ test('Does not send HttpExceptions to Sentry', async ({ baseURL }) => { await transactionEventPromise400; await transactionEventPromise500; - await fetch(`${baseURL}/flush`); + (await fetch(`${baseURL}/flush`)).text(); expect(errorEventOccurred).toBe(false); }); @@ -90,7 +90,7 @@ test('Does not send RpcExceptions to Sentry', async ({ baseURL }) => { await transactionEventPromise; - await fetch(`${baseURL}/flush`); + (await fetch(`${baseURL}/flush`)).text(); expect(errorEventOccurred).toBe(false); }); From a556081500d829e7916d0748416a0a7f91b44858 Mon Sep 17 00:00:00 2001 From: nicohrubec Date: Tue, 6 Aug 2024 09:33:28 +0200 Subject: [PATCH 3/3] . --- .../test-applications/nestjs-basic/tests/errors.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/errors.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/errors.test.ts index e2b1555c2b35..34e626cb8c52 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/errors.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/errors.test.ts @@ -65,7 +65,7 @@ test('Does not send HttpExceptions to Sentry', async ({ baseURL }) => { await transactionEventPromise400; await transactionEventPromise500; - await fetch(`${baseURL}/flush`); + (await fetch(`${baseURL}/flush`)).text(); expect(errorEventOccurred).toBe(false); }); @@ -90,7 +90,7 @@ test('Does not send RpcExceptions to Sentry', async ({ baseURL }) => { await transactionEventPromise; - await fetch(`${baseURL}/flush`); + (await fetch(`${baseURL}/flush`)).text(); expect(errorEventOccurred).toBe(false); });