There is a documented issue describing how axios and nock do not work well together. The workaround described in this comment works.
import axios from 'axios';
import httpAdapter from 'axios/lib/adapters/http';
import nock from 'nock';
axios.defaults.adapter = httpAdapter;
// Some tests using nock ...
The problem with this solution is that Typescript complains httpAdapter
from axios/lib/adapters/http
implicitly has the any
type. To combat this, add a definitions file to your project with the contents of axios.d.ts.