简体   繁体   English

使用 Jest 进行 Strapi 单元测试,失败

[英]Strapi unit testing with Jest, fails

I have a Strapi api and trying to run a unit test我有一个 Strapi api 并尝试运行单元测试

this is the error in the console I am getting这是我收到的控制台中的错误

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.

I followed these instructions exactly.我完全按照这些说明进行操作。

How can I fix this issue?我该如何解决这个问题?

Thanks谢谢

通过将env文件夹名称更改为环境来解决该问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM