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

Commit

Permalink
Test coverage, test for app service (#73)
Browse files Browse the repository at this point in the history
* empty commit

* added test for getPing in app service
  • Loading branch information
OG-NI authored and henrybrink committed Apr 4, 2024
1 parent f3143c4 commit e45c2d1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
26 changes: 26 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "npm run test:unit && npm run test:e2e",
"test": "jest",
"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:unit": "jest"
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^10.0.0",
Expand Down Expand Up @@ -65,6 +64,13 @@
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
"testEnvironment": "node",
"coverageThreshold": {
"global": {
"lines": 90,
"functions": 90,
"branches": 90
}
}
}
}
2 changes: 1 addition & 1 deletion backend/src/app.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('AppController', () => {
});

describe('getPing', () => {
it('should return pong on ping', () => {
it('should call getPing in app service', () => {
jest.spyOn(appService, 'getPing').mockReturnValue('pong');
expect(appController.getPing()).toBe('pong');
});
Expand Down
15 changes: 15 additions & 0 deletions backend/src/app.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { AppService } from './app.service';

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

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

describe('getPing', () => {
it('should return pong on getPing', () => {
expect(appService.getPing()).toBe('pong');
});
});
});

0 comments on commit e45c2d1

Please sign in to comment.