【发布时间】:2020-06-02 18:39:13
【问题描述】:
我正在尝试使用 Strapi,并希望创建一个通过单元测试验证的控制器。
如何在 Strapi 中设置单元测试?
我已经写了下面的测试
test('checks entity inside boundary',async ()=> {
ctx={};
var result = await controller.findnearby(ctx);
result = {};
expect(result).anyting();
});
但是,在我的 Controller 中,我有代码可以访问一个全局的strapi 对象,这会导致这个错误ReferenceError: strapi is not defined
strapi.log.info('findNearby');
strapi.log.info(ctx.request.query.lat);
strapi.log.info(ctx.request.query.long);
Strapi 和测试的最佳做法是什么?
【问题讨论】:
标签: node.js unit-testing jestjs strapi