diff --git a/api/package.json b/api/package.json index 955912b..09caa50 100644 --- a/api/package.json +++ b/api/package.json @@ -14,10 +14,10 @@ "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest", - "test:watch": "jest --watch", + "test:recent": "jest --onlyChanged", + "test:watch": "jest --watch --onlyChanged", "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:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand" }, "dependencies": { "@nestjs/axios": "^3.0.3", @@ -61,22 +61,5 @@ "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", "typescript": "^5.1.3" - }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": "src", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "testEnvironment": "node" } } diff --git a/api/src/modules/auth/auth.service.spec.ts b/api/src/modules/auth/auth.service.spec.ts new file mode 100644 index 0000000..c1559c8 --- /dev/null +++ b/api/src/modules/auth/auth.service.spec.ts @@ -0,0 +1,33 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { AuthService } from './auth.service'; +import { HttpService } from '@nestjs/axios'; +import { UserRepository } from 'src/model/repositories'; +import { ConfigService } from '@nestjs/config'; +import { JwtService } from '@nestjs/jwt'; + +describe('AppService', () => { + let service: AuthService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [AuthService, + {provide: UserRepository, useClass: MockUserRepository}, + {provide: HttpService, useClass: MockHttpService}, + ConfigService, + JwtService + ], + }).compile(); + + service = module.get(AuthService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); + +class MockUserRepository { + +} + +class MockHttpService {} \ No newline at end of file diff --git a/api/test/app.e2e-spec.ts b/api/test/app.e2e-spec.ts deleted file mode 100644 index 50cda62..0000000 --- a/api/test/app.e2e-spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; -import { AppModule } from './../src/app.module'; - -describe('AppController (e2e)', () => { - let app: INestApplication; - - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); - - app = moduleFixture.createNestApplication(); - await app.init(); - }); - - it('/ (GET)', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect('Hello World!'); - }); -}); diff --git a/api/test/jest-e2e.json b/api/test/jest-e2e.json deleted file mode 100644 index e9d912f..0000000 --- a/api/test/jest-e2e.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "moduleFileExtensions": ["js", "json", "ts"], - "rootDir": ".", - "testEnvironment": "node", - "testRegex": ".e2e-spec.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } -} diff --git a/client/package.json b/client/package.json index 01776b6..6066a96 100644 --- a/client/package.json +++ b/client/package.json @@ -7,6 +7,7 @@ "build": "ng build", "watch": "ng build --watch --configuration development", "test": "jest", + "test:recent": "jest --onlyChanged", "test:watch": "jest --watch --onlyChanged" }, "private": true,