Jest returns “Network Error” when doing an authenticated request with axios

后端 未结 4 601
被撕碎了的回忆
被撕碎了的回忆 2021-02-02 09:14

This seems a bit weird to me. I\'m trying to test an actual (ie. real network) request with Jest.

These are the tested scenarios:

  • Test an external API (fix
4条回答
  •  花落未央
    2021-02-02 09:16

    It can be a Jest configuration issue. I solved forcing "node" as jest environment in package.json:

    "jest": { "testEnvironment": "node" }

    see docs: https://facebook.github.io/jest/docs/configuration.html#testenvironment-string

提交回复
热议问题