Tests: Clear API mocks between each test
This commit is contained in:
parent
842f35ebc5
commit
f71f7e4dbd
3 changed files with 4 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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>');
|
||||
}));
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue