测试
在 Midway Hooks 中,我们可以快速的对 Http 接口进行测试。
接口测试
此处以 Hello World 为例,我们在 src/hello.ts
中,导出了一个接口,代码如下。
import { Api, Get } from '@midwayjs/hooks';
export default Api(Get('/hello'), async () => {
return 'Hello World!';
});
在测试中,你可以通过 @midwayjs/mock
去启动应用,并调用接口完成测试。