From 33ba85a9f25ff4bfb549dbece198401cfc8b5db7 Mon Sep 17 00:00:00 2001 From: Gabriel Ignat Date: Mon, 6 Feb 2023 08:26:57 +0000 Subject: [PATCH] chore: updated the `jest` configs (#4) --- .eslintrc.js | 10 +++++++--- README.md | 11 ++++++----- jest.config.js | 10 ++++++++++ package.json | 17 ----------------- src/modules/healthcheck/healthcheck.module.ts | 2 +- src/modules/numbers/numbers.service.ts | 2 +- 6 files changed, 25 insertions(+), 27 deletions(-) create mode 100644 jest.config.js diff --git a/.eslintrc.js b/.eslintrc.js index ad8d92da..f4a9d439 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -55,15 +55,12 @@ module.exports = { }, ], 'no-console': ['error', { allow: ['info', 'error'] }], - 'no-underscore-dangle': ['error', { allow: ['_id'] }], 'import/no-named-as-default': 'off', 'import/extensions': 'off', 'implicit-arrow-linebreak': 'off', 'import/newline-after-import': 'off', - 'import/first': 'off', 'import/prefer-default-export': 'off', 'consistent-return': 'off', - 'import/order': 'off', '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/no-explicit-any': 'off', @@ -73,5 +70,12 @@ module.exports = { 'require-await': 'error', 'no-useless-constructor': 'off', 'class-methods-use-this': 'off', + 'object-curly-newline': [ + 'error', + { + consistent: true, + }, + ], }, + ignorePatterns: ['**/node_modules/**', 'jest.config.js'], }; diff --git a/README.md b/README.md index fb3d81f0..e1b00775 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -### Description +# Description [NestJS](https://github.com/nestjs/nest) framework TypeScript starter repository. -#### Features +## Features - [x] MSSQL TypeORM setup - [x] Dockerised application using NodeJS v19 @@ -15,6 +15,7 @@ - [x] Swagger based documentation - [x] Config based on ENV variables - [x] Automated API versioning `(/v1)` +- [x] Configuration for `Jest` tests - [x] Automated releases based on conventional commits - [x] Automated version bumps based on commit messages - [ ] Configuration for Jest tests @@ -29,10 +30,10 @@ - [ ] Add security headers - [ ] Deployment pipelines -### Installation +## Installation ```bash -$ npm install +npm install ``` ### Running the service (dev) @@ -62,7 +63,7 @@ $ npm run api-test To simplify the generation of new resources, you can use the boilerplate [CRUD](https://docs.nestjs.com/recipes/crud-generator) ```bash -$ nest g resource users +nest g resource users ``` ### Writing Conventional Commits diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..2a483db4 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + collectCoverageFrom: ['**/*.ts'], + coverageDirectory: 'generated_reports/api-test', + testMatch: ['**/*.spec.ts'], + rootDir: 'src', + transform: { '^.+\\.(t|j)s$': 'ts-jest' }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'node'], + preset: 'ts-jest', + testEnvironment: 'node', +}; diff --git a/package.json b/package.json index 5fd2a7ef..04a6b0eb 100644 --- a/package.json +++ b/package.json @@ -77,22 +77,5 @@ "ts-node": "^10.9.1", "tsconfig-paths": "4.1.2", "typescript": "^4.9.5" - }, - "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/src/modules/healthcheck/healthcheck.module.ts b/src/modules/healthcheck/healthcheck.module.ts index c87c6ea3..031670dc 100644 --- a/src/modules/healthcheck/healthcheck.module.ts +++ b/src/modules/healthcheck/healthcheck.module.ts @@ -1,7 +1,7 @@ import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; import { HealthcheckController } from './healthcheck.controller'; import { HealthcheckService } from './healthcheck.service'; -import { TypeOrmModule } from '@nestjs/typeorm'; import { UkefId } from '../numbers/entities/ukef-id.entity'; import { MarketEntity } from '../markets/entities/market.entity'; diff --git a/src/modules/numbers/numbers.service.ts b/src/modules/numbers/numbers.service.ts index f9622b79..8633c1e2 100644 --- a/src/modules/numbers/numbers.service.ts +++ b/src/modules/numbers/numbers.service.ts @@ -1,7 +1,7 @@ import { Injectable, NotFoundException } from '@nestjs/common'; -import { CreateUkefIdDto } from './dto/create-ukef-id.dto'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; +import { CreateUkefIdDto } from './dto/create-ukef-id.dto'; import { UkefId } from './entities/ukef-id.entity'; @Injectable()