mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat: initialize the server e2e tests
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/modules/App/App.module';
|
||||
|
||||
describe('AppController (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!');
|
||||
});
|
||||
});
|
||||
20
packages/server-nest/test/init-app-test.ts
Normal file
20
packages/server-nest/test/init-app-test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AppModule } from '../src/modules/App/App.module';
|
||||
|
||||
let app: INestApplication;
|
||||
|
||||
beforeAll(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
export { app };
|
||||
19
packages/server-nest/test/items.e2e-spec.ts
Normal file
19
packages/server-nest/test/items.e2e-spec.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { AppModule } from '../src/modules/App/App.module';
|
||||
import { app } from './init-app-test';
|
||||
|
||||
describe('Items (e2e)', () => {
|
||||
it('/items (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/items')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
name: faker.commerce.productName(),
|
||||
type: 'service',
|
||||
})
|
||||
.expect(201);
|
||||
});
|
||||
});
|
||||
@@ -5,5 +5,8 @@
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"moduleNameMapper": {
|
||||
"^@/(.*)$": "<rootDir>/../src/$1"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user