diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 0000000..9442e04 --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,18 @@ +import type { Config } from '@jest/types'; +const config: Config.InitialOptions = { + moduleFileExtensions: ['ts', 'js', 'json'], + modulePaths: [''], + roots: ['/src/', '/test/'], + testRegex: '.*\\.(test|spec)\\.[jt]s$', + transform: { '\\.[jt]s$': 'ts-jest' }, + collectCoverageFrom: ['**/*.[jt]s'], + coverageDirectory: 'coverage', + coveragePathIgnorePatterns: [ + '/node_modules/', + '.*\\.module\\.[jt]s$', + ], + // moduleDirectories: ['node_modules'], // default is already 'node_modules' + // rootDir: '.', //No need + // testEnvironment: 'node', //Defaults to 'node' +}; +export default config; diff --git a/package.json b/package.json index e66072f..9b6262c 100644 --- a/package.json +++ b/package.json @@ -91,28 +91,5 @@ "ts-node": "^10.8.1", "tsconfig-paths": "^3.14.1", "typescript": "^4.6.3" - }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": ".", - "modulePaths": [ - "" - ], - "moduleDirectories": [ - "node_modules" - ], - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "testEnvironment": "node" } } diff --git a/src/modules/connection-test/connection-test.controller.spec.ts b/src/modules/connection-test/connection-test.controller.spec.ts deleted file mode 100644 index 6744a3b..0000000 --- a/src/modules/connection-test/connection-test.controller.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { ConnectionTestController } from './connection-test.controller'; -import { ConnectionTestService } from './connection-test.service'; -import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; -import { ConnectionTestClientConfiguration } from './connection-test-client.config'; -import { ClientsModule } from '@nestjs/microservices'; - -describe('ConnectionTestController', () => { - let controller: ConnectionTestController; - - beforeEach(async () => { - const client = new ConnectionTestClientConfiguration(); - const module: TestingModule = await Test.createTestingModule({ - controllers: [ConnectionTestController], - providers: [ConnectionTestService, DadosferaLogger], - imports: [ClientsModule.register([client.providerOptions])], - }).compile(); - - controller = module.get(ConnectionTestController); - }); - - it('should be defined', () => { - expect(controller).toBeDefined(); - }); -}); diff --git a/src/modules/connection-test/connection-test.service.spec.ts b/src/modules/connection-test/connection-test.service.spec.ts deleted file mode 100644 index 3550ffc..0000000 --- a/src/modules/connection-test/connection-test.service.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { ConnectionTestController } from './connection-test.controller'; -import { ConnectionTestService } from './connection-test.service'; -import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; -import { ConnectionTestClientConfiguration } from './connection-test-client.config'; -import { ClientsModule } from '@nestjs/microservices'; - -describe('ConnectionTestService', () => { - let service: ConnectionTestService; - - beforeEach(async () => { - const client = new ConnectionTestClientConfiguration(); - const module: TestingModule = await Test.createTestingModule({ - controllers: [ConnectionTestController], - providers: [ConnectionTestService, DadosferaLogger], - imports: [ClientsModule.register([client.providerOptions])], - }).compile(); - - service = module.get(ConnectionTestService); - }); - - it('should be defined', () => { - expect(service).toBeDefined(); - }); -});