Skip to content

Commit

Permalink
fix: improve test robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Mar 3, 2025
1 parent e4360d5 commit cb13325
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/routes/common/filters/global-error.filter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ describe('GlobalErrorFilter tests', () => {

describe('responses', () => {
it('http exception returns correct error code and message', async () => {
const code = faker.internet.httpStatusCode();
const code = faker.internet.httpStatusCode({
types: ['clientError', 'serverError'],
});

await request(app.getHttpServer())
.post('/http-exception')
Expand All @@ -83,7 +85,9 @@ describe('GlobalErrorFilter tests', () => {
});

it('no log http exception returns correct error code and message', async () => {
const code = faker.internet.httpStatusCode();
const code = faker.internet.httpStatusCode({
types: ['clientError', 'serverError'],
});

await request(app.getHttpServer())
.post('/no-log-http-exception')
Expand Down Expand Up @@ -123,7 +127,7 @@ describe('GlobalErrorFilter tests', () => {

it('should log non-server errors as info', async () => {
const code = faker.internet.httpStatusCode({
types: ['informational', 'success', 'clientError', 'redirection'],
types: ['clientError'],
});

await request(app.getHttpServer())
Expand All @@ -141,7 +145,9 @@ describe('GlobalErrorFilter tests', () => {
});

it('should not log no log http exception', async () => {
const code = faker.internet.httpStatusCode();
const code = faker.internet.httpStatusCode({
types: ['clientError', 'serverError'],
});

await request(app.getHttpServer())
.post('/no-log-http-exception')
Expand Down

0 comments on commit cb13325

Please sign in to comment.