lundi 18 septembre 2017

Will this mock be visibile outside of this test?

I see a test that has a jest.mock call outside of a describe block.

I am concerned this will create a change visible outside of the test. I do not want this test affecting other tests.

Should jest.mock be moved inside the describe block or is it OK as-is?

import target from '../';

jest.mock('../../../helpers/helpers.api', () => ({
    httpPost(...args) {
        return args;
    }
}));

describe('my component', () => {
    it('should foo', () => {
        //... 
    });
});

Aucun commentaire:

Enregistrer un commentaire