Skip to content

Commit

Permalink
working api jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed May 16, 2024
1 parent b8de3d6 commit 86f7d4d
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 23 deletions.
17 changes: 0 additions & 17 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,5 @@
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3",
"ts-node": "^10.9.2"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
2 changes: 1 addition & 1 deletion api/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { AppService } from '@api/app.service';

@Controller()
export class AppController {
Expand Down
2 changes: 1 addition & 1 deletion api/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { AppService } from '@api/app.service';
import { UsersModule } from '@api/modules/users/users.module';

@Module({
Expand Down
4 changes: 1 addition & 3 deletions api/src/modules/users/users.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Controller, Get } from '@nestjs/common';
import { userContract } from '@shared/contracts/user.contract';
const contract = userContract;

@Controller()
export class UsersController {
@Get(contract.createUser.path)
@Get('users')
createUser() {
return 'This action adds a new user';
}
Expand Down
6 changes: 6 additions & 0 deletions api/test/jest-e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},

"moduleNameMapper": {
"^@api/(.*)$": "<rootDir>/src/$1",
"^@client/(.*)$": "<rootDir>/../client/src/$1",
"^@shared/(.*)$": "<rootDir>/../shared/$1"
}
}
2 changes: 1 addition & 1 deletion api/test/users/users.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { UsersService } from '../../src/modules/users/users.service';
import { UsersService } from '@api/modules/users/users.service';

describe('UsersService', () => {
let service: UsersService;
Expand Down
1 change: 1 addition & 0 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"strictPropertyInitialization": false,
"plugins": [
{
"name": "next"
Expand Down

0 comments on commit 86f7d4d

Please sign in to comment.