本文整理汇总了TypeScript中@nestjs/common.INestApplication.getHttpServer方法的典型用法代码示例。如果您正苦于以下问题:TypeScript INestApplication.getHttpServer方法的具体用法?TypeScript INestApplication.getHttpServer怎么用?TypeScript INestApplication.getHttpServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@nestjs/common.INestApplication
的用法示例。
在下文中一共展示了INestApplication.getHttpServer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(async () => {
const module = await Test.createTestingModule({
imports: [AsyncOptionsFactoryModule],
}).compile();
app = module.createNestApplication();
server = app.getHttpServer();
await app.init();
});
示例2: it
it(`should map response (stream)`, async () => {
app = (await createTestModule(
new TransformInterceptor(),
)).createNestApplication();
await app.init();
return request(app.getHttpServer())
.get('/hello/async')
.expect(200, { data: 'Hello world!' });
});
示例3: it
it(`should prevent access (unauthorized)`, async () => {
app = (await createTestModule(
new AuthGuard(),
)).createNestApplication();
await app.init();
return request(app.getHttpServer())
.get('/hello')
.expect(401);
});
示例4: beforeEach
beforeEach(async () => {
const module = await Test.createTestingModule({
controllers: [ErrorsController],
})
.compile();
app = module.createNestApplication();
server = app.getHttpServer();
await app.init();
});
示例5: it
it('/api/contact (POST)', () => {
const contactRequest: ContactRequest = {
message: 'my contact request',
email: 'somebody@somewhere',
name: 'somebody',
};
return request(app.getHttpServer())
.post(`/${PATHS.CONTACT}`)
.send(contactRequest)
.expect(201);
});
示例6: it
it(`should return query result`, () => {
return request(app.getHttpServer())
.post('/graphql')
.send({
operationName: null,
variables: {},
query: '{\n getCats {\n id\n }\n}\n',
})
.expect(200, {
data: {
getCats: [
{
id: 1,
},
],
},
});
});
示例7: it
it('/GET ip', () => {
return request(app.getHttpServer())
.get('/ip')
.expect(200)
.expect('::ffff:127.0.0.1');
});
示例8: it
it(`/GET /cars/:id - Get a cars`, async () => {
return request(app.getHttpServer())
.get('/cars/222222')
.expect(200)
.expect(carService.getById());
});