Skip to content

Commit 49db280

Browse files
committed
test: updated tests
1 parent 2fac4d6 commit 49db280

File tree

10 files changed

+15
-19
lines changed

10 files changed

+15
-19
lines changed

tests/e2e/api/Health.controller.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,22 @@ import { createNestTestApplicationOptions, startNestApplication } from 'tests/e2
88
jest.setTimeout(5000);
99
describe('API :: HealthController', () => {
1010
let nestTestApp: INestApplication;
11-
let nestTestingModule: TestingModule;
1211

1312
// ? build test app
1413
beforeAll(async () => {
15-
nestTestingModule = await Test.createTestingModule({
14+
const nestTestingModule: TestingModule = await Test.createTestingModule({
1615
imports: [CoreModule],
1716
}).compile();
1817

1918
nestTestApp = nestTestingModule.createNestApplication(createNestTestApplicationOptions);
2019
await startNestApplication(nestTestApp);
21-
await nestTestApp.init();
2220
});
2321

2422
afterEach(() => {
2523
jest.clearAllMocks();
2624
});
2725
afterAll(async () => {
2826
await nestTestApp.close();
29-
await nestTestingModule.close();
3027
});
3128

3229
describe('# [GET] /api/check', () => {

tests/e2e/api/User.controller.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,22 @@ import { createNestTestApplicationOptions, startNestApplication } from 'tests/e2
88
jest.setTimeout(1.2 * 5000);
99
describe('API :: UserController', () => {
1010
let nestTestApp: INestApplication;
11-
let nestTestingModule: TestingModule;
1211

1312
// ? build test app
1413
beforeAll(async () => {
15-
nestTestingModule = await Test.createTestingModule({
14+
const nestTestingModule: TestingModule = await Test.createTestingModule({
1615
imports: [CoreModule],
1716
}).compile();
1817

1918
nestTestApp = nestTestingModule.createNestApplication(createNestTestApplicationOptions);
2019
await startNestApplication(nestTestApp);
21-
await nestTestApp.init();
2220
});
2321

2422
afterEach(() => {
2523
jest.clearAllMocks();
2624
});
2725
afterAll(async () => {
2826
await nestTestApp.close();
29-
await nestTestingModule.close();
3027
});
3128

3229
describe('# [GET] /api/users', () => {

tests/e2e/support/setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import dotenv from 'dotenv';
22

33

4-
dotenv.config({ path: '.env.test' });
4+
dotenv.config({ path: '.env' });
5+
process.env.NODE_ENV = 'test';

tests/integration/modules/api/controllers/Health.controller.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { createNestTestApplicationOptions, startNestApplication } from 'tests/in
1010

1111
describe('Modules :: API :: HealthController', () => {
1212
let nestTestApp: INestApplication;
13-
let nestTestingModule: TestingModule;
13+
1414
// // mocks
1515
const customThrottlerGuardMock = {
1616
handleRequest: jest.fn((..._args: unknown[]): Promise<boolean> => { return Promise.resolve(true); }),
@@ -23,7 +23,7 @@ describe('Modules :: API :: HealthController', () => {
2323

2424
// ? build test app
2525
beforeAll(async () => {
26-
nestTestingModule = await Test.createTestingModule({
26+
const nestTestingModule: TestingModule = await Test.createTestingModule({
2727
imports: [],
2828
controllers: [
2929
HealthController,
@@ -41,15 +41,13 @@ describe('Modules :: API :: HealthController', () => {
4141

4242
nestTestApp = nestTestingModule.createNestApplication(createNestTestApplicationOptions);
4343
await startNestApplication(nestTestApp);
44-
await nestTestApp.init();
4544
});
4645

4746
afterEach(() => {
4847
jest.clearAllMocks();
4948
});
5049
afterAll(async () => {
5150
await nestTestApp.close();
52-
await nestTestingModule.close();
5351
});
5452

5553
describe('# [GET] /api/check', () => {

tests/integration/modules/app/user/api/controllers/User.controller.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { ListQueryInterface } from '@shared/internal/interfaces/listPaginationIn
2222

2323
describe('Modules :: App :: User :: API :: UserController', () => {
2424
let nestTestApp: INestApplication;
25-
let nestTestingModule: TestingModule;
25+
2626
// // mocks
2727
const customThrottlerGuardMock = {
2828
handleRequest: jest.fn((..._args: unknown[]): Promise<boolean> => { return Promise.resolve(true); }),
@@ -37,7 +37,7 @@ describe('Modules :: App :: User :: API :: UserController', () => {
3737

3838
// ? build test app
3939
beforeAll(async () => {
40-
nestTestingModule = await Test.createTestingModule({
40+
const nestTestingModule: TestingModule = await Test.createTestingModule({
4141
imports: [],
4242
controllers: [
4343
UserController,
@@ -62,15 +62,13 @@ describe('Modules :: App :: User :: API :: UserController', () => {
6262

6363
nestTestApp = nestTestingModule.createNestApplication(createNestTestApplicationOptions);
6464
await startNestApplication(nestTestApp);
65-
await nestTestApp.init();
6665
});
6766

6867
afterEach(() => {
6968
jest.clearAllMocks();
7069
});
7170
afterAll(async () => {
7271
await nestTestApp.close();
73-
await nestTestingModule.close();
7472
});
7573

7674
describe('# [GET] /api/users', () => {

tests/integration/modules/app/user/services/User.service.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { configServiceMock } from '@dev/mocks/mockedModules';
1212
describe('Modules :: App :: User :: Services :: UserService', () => {
1313
let nestTestingModule: TestingModule;
1414
let userService: UserService;
15+
1516
// // mocks
1617
const userRepositoryMock = {
1718
getById: jest.fn(async (_id: string, _withoutPassword?: boolean): Promise<UserEntity | null> => (null)),

tests/integration/modules/app/user/services/UserPreference.service.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { configServiceMock } from '@dev/mocks/mockedModules';
1212
describe('Modules :: App :: User :: Services :: UserPreferenceService', () => {
1313
let nestTestingModule: TestingModule;
1414
let userPreferenceService: UserPreferenceService;
15+
1516
// // mocks
1617
const userPreferenceRepositoryMock = {
1718
findOne: jest.fn(async (_query: FindOneOptions<UserPreferencesModel>): Promise<UserPreferenceEntity | null> => (null)),

tests/integration/modules/core/start/Lifecycle.service.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { mockObservable } from 'tests/integration/support/mocks/mockObservable';
2020

2121
describe('Modules :: Core :: Start :: LifecycleService', () => {
2222
let nestTestingModule: TestingModule;
23+
2324
// // mocks
2425
const databaseConnectionMock = {
2526
destroy: jest.fn((...args: unknown[]): void => { args.forEach((arg) => console.log(arg)); }),

tests/integration/support/setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { Server, ServerSocket } from './mocks/webSocket/socket.io';
55
import { ClientSocket } from './mocks/webSocket/socket.io-client';
66

77

8-
dotenv.config({ path: '.env.test' });
8+
dotenv.config({ path: '.env' });
9+
process.env.NODE_ENV = 'test';
910

1011
// * backing services and dependencies mocks
1112
jest.mock('@core/logging/Logger.service.ts', () => jest.requireActual('./mocks/logging/Logger.service'));

tests/unit/support/setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import dotenv from 'dotenv';
22

33

4-
dotenv.config({ path: '.env.test' });
4+
dotenv.config({ path: '.env' });
5+
process.env.NODE_ENV = 'test';

0 commit comments

Comments
 (0)