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

Test coverage, test for app service #73

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
});
Loading