Skip to content

Commit

Permalink
doing e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
morteza-mortezai committed May 18, 2023
1 parent 8fa857f commit 93a2fda
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 90 deletions.

This file was deleted.

File renamed without changes.
File renamed without changes.

This file was deleted.

18 changes: 0 additions & 18 deletions apps/users/src/infrastructure/data-source/user.repository.spec.ts

This file was deleted.

24 changes: 24 additions & 0 deletions apps/users/test/app.e2e-sp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';

describe('BillingController (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!');
});
});
29 changes: 11 additions & 18 deletions apps/users/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import * as request from 'supertest';
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';

describe('BillingController (e2e)', () => {
let app: INestApplication;

beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();

app = moduleFixture.createNestApplication();
await app.init();
});
describe('User Controller', () => {
let app: INestApplication;

it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
beforeAll(async () => {
const moduleRef: TestingModule = await Test.createTestingModule({
imports: [AppModule]
})
.compile()
app = moduleRef.createNestApplication();
await app.init();
});
});
23 changes: 19 additions & 4 deletions apps/users/test/jest-e2e.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
"^.+\\.(t|j)s$": [
"ts-jest",
{
"useESM": true
}
]
},
"moduleNameMapper": {
"^@app/common(|/.*)$": "<rootDir>/libs/common/src/$1"
},
"extensionsToTreatAsEsm": [
".ts"
]
}
2 changes: 1 addition & 1 deletion apps/users/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"dist",
"test",
"**/*spec.ts"
]
],
}
3 changes: 0 additions & 3 deletions libs/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// export * from './database/abstract.schema';
// export * from './database/abstract.repository';
// export * from './database/database.module';
export * from './rmq/rmq.module';
export * from './rmq/rmq.service';
export * from './hash/hash.module';
Expand Down
9 changes: 0 additions & 9 deletions nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@
"tsConfigPath": "libs/common/tsconfig.lib.json"
}
},
"other-microservice": {
"type": "application",
"root": "apps/other-microservice",
"entryFile": "main",
"sourceRoot": "apps/other-microservice/src",
"compilerOptions": {
"tsConfigPath": "apps/other-microservice/tsconfig.app.json"
}
},
"mailer": {
"type": "application",
"root": "apps/mailer",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "jest --watch",
"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 ./apps/ordering-app/test/jest-e2e.json"
"test:e2e": "jest --config ./apps/users/test/jest-e2e.json"
},
"dependencies": {
"@nestjs-modules/mailer": "^1.8.1",
Expand Down

0 comments on commit 93a2fda

Please sign in to comment.