簡體   English   中英

使用 Jest 進行 Strapi 單元測試,失敗

[英]Strapi unit testing with Jest, fails

我有一個 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文件夾名稱更改為環境來解決該問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM