Tests: Clear API mocks between each test

This commit is contained in:
Alex Gleason 2020-06-09 17:16:22 -05:00
parent 842f35ebc5
commit f71f7e4dbd
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3 changed files with 4 additions and 1 deletions

View file

@ -4,6 +4,7 @@ const api = jest.requireActual('../api').default;
let mocks = [];
export const __stub = func => mocks.push(func);
export const __clear = () => mocks = [];
const setupMock = axios => {
const mock = new MockAdapter(axios);

View file

@ -12,7 +12,7 @@ const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
describe('fetchAboutPage()', () => {
beforeAll(() => stubApi(mock => {
beforeEach(() => stubApi(mock => {
mock.onGet('/instance/about/index.html').reply(200, '<h1>Hello world</h1>');
}));

View file

@ -2,8 +2,10 @@
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { __clear as clearApiMocks } from 'soapbox/api';
const adapter = new Adapter();
configure({ adapter });
jest.mock('soapbox/api');
afterEach(() => clearApiMocks());