【发布时间】:2021-11-22 00:18:36
【问题描述】:
test.controller.ts
import { Controller, Get, Res } from '@nestjs/common';
@Controller('test')
export class TestController {
@Get()
check(@Res() response) {
response.status(200).send();
}
}
test.controller.spec.ts
import { Test, TestingModule } from '@nestjs/testing';
import { TestController } from './test.controller';
describe('TestController', () => {
let controller: TestController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [TestController],
}).compile();
controller = module.get<TestController>(TestController);
});
describe('check', () => {
it('should return status 200', async () => {
const result = 'test'
expect(await controller.check()).toBe(result);
});
)
});
当前代码是这样的。 我想要 200 的状态,但我不知道在这种情况下如何预期结果。
【问题讨论】:
标签: typescript jestjs nestjs