简体   繁体   中英

Strapi unit testing with Jest, fails

I have a Strapi api and trying to run a unit test

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文件夹名称更改为环境来解决该问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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