5

I am trying to run some integration tests for react using jest. When running the test, I get the following error UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:" . Initially I though was related to msw mocking my api calls, but even after disabling the msw server I am still getting this erros.

I am using axios in my app to make http requests, and all URLs are set to use HTTPS. I also told jest both in a setup file and jest.config to use https when mocking origin, but it's still not working. Any ideas what else I can try?

Adrian Pascu
  • 949
  • 5
  • 20
  • 48
  • Instead of doing the actual `http` calls you can mock `axios` and check whether your app is requesting the correct endpoint with the correct data and mock the responses – Teneff Jan 15 '21 at 07:39

0 Answers0