node.js - 使用 Jest 进行 Strapi 单元测试,失败
问题描述
我有一个 Strapi api 并试图运行一个单元测试
这是我得到的控制台中的错误
yarn test
yarn run v1.22.5
$ jest --forceExit --detectOpenHandles
● process.exit called with "1"
8 | if (!instance) {
9 | /** the follwing code in copied from `./node_modules/strapi/lib/Strapi.js` */
> 10 | await Strapi().load();
| ^
11 | instance = strapi; // strapi is global now
12 | await instance.app
13 | .use(instance.router.routes()) // populate KOA routes
at Strapi.stop (node_modules/strapi/lib/Strapi.js:263:13)
at node_modules/strapi/lib/Strapi.js:391:16
at async Promise.all (index 5)
at Strapi.runBootstrapFunctions (node_modules/strapi/lib/Strapi.js:394:5)
at Strapi.load (node_modules/strapi/lib/Strapi.js:326:5)
at setupStrapi (tests/helpers/strapi.js:10:5)
at Object.<anonymous> (tests/app.test.js:8:3)
RUNS tests/app.test.js
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
我完全按照这些说明进行操作。
我该如何解决这个问题?
谢谢
解决方案
通过将env文件夹名称更改为环境来解决该问题
推荐阅读
- html - 使用基于 Jquery 的数据属性基于字母选择显示元素
- flutter - 颤振 - 我希望图像离开该区域时消失
- javascript - 如何截取 Scratch 项目的 Electron 应用程序?
- python - 获取两个子字符串之间的文本python
- spring-boot - springboot kotlin应用程序中如何避免空指针异常
- java - Java I/O 问题 字符串已写入但未显示在文件中
- android - 所有版本的房间数据库迁移
- c - 从 for 循环中检索多个值到单独的函数中进行比较
- python - 如何快速将大量数据转换为字符串?
- python - 配置 django logger 以每 24 小时执行一次写入日志到单独的文件