rogeliog / jest-runner-mocha

A Mocha runner for Jest
70 stars 12 forks source link

setupFilesAfterEnv and clearMocks support #25

Open jehy opened 4 years ago

jehy commented 4 years ago

This is a quick and a bit dirty solution for https://github.com/rogeliog/jest-runner-mocha/issues/24

It does not break anything but lets you use setupFilesAfterEnv and use clearMocks if it is enabled and exported from one of the setup files.

For example, we use sinon but we can enjoy independent mocks with a simple clearMocks implementation:

const sinon = require('sinon');
module.exports = {
    clearMocks: () => {
        sinon.sandbox.restore();
    }
};

I'm not sure if it will play as well with clearing jests's native mocks - but right now clearing native mocks does't work anyway.