Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
ping testing (#71)
Browse files Browse the repository at this point in the history
* ping testing

* empty commit
  • Loading branch information
OG-NI authored and henrybrink committed Apr 4, 2024
1 parent 96c6c12 commit f3143c4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 31 deletions.
5 changes: 3 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test": "npm run test:unit && npm run test:e2e",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
"test:e2e": "jest --config ./test/jest-e2e.json",
"test:unit": "jest"
},
"dependencies": {
"@nestjs/common": "^10.0.0",
Expand Down
19 changes: 19 additions & 0 deletions backend/src/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { AppController } from './app.controller';
import { AppService } from './app.service';

describe('AppController', () => {
let appController: AppController;
let appService: AppService;

beforeEach(async () => {
appService = new AppService();
appController = new AppController(appService);
});

describe('getPing', () => {
it('should return pong on ping', () => {
jest.spyOn(appService, 'getPing').mockReturnValue('pong');
expect(appController.getPing()).toBe('pong');
});
});
});
9 changes: 3 additions & 6 deletions backend/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './../src/app.module';
import { AppModule } from '../src/app.module';

describe('AppController (e2e)', () => {
let app: INestApplication;
Expand All @@ -15,10 +15,7 @@ describe('AppController (e2e)', () => {
await app.init();
});

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
it('/ping (GET)', () => {
return request(app.getHttpServer()).get('/ping').expect(200).expect('pong');
});
});
2 changes: 1 addition & 1 deletion backend/test/jest-e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
Expand Down
22 changes: 0 additions & 22 deletions backend/test/src/app.controller.spec.ts

This file was deleted.

0 comments on commit f3143c4

Please sign in to comment.