-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Milestone
Description
Hello! Thanks for your amazing work with the new version of Jest.
I know that the deepUnmock function is not documented (yet?) but I was following #1188 and I would really love to use it.
However, I found out that it works only with require and it doesn't with modules (unless there's something wrong with the following code).
Is there a reason for that? Can I apply a workaround or something?
Config
"jest": {
"automock": true
}ES5 😻
// ./__tests__/test.js
jest.deepUnmock('../src/sum-1');
var sum = require('../src/sum-1');
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});// ./src/sum-1.js
var sum = require('./sum-2');
module.exports = sum// ./src/sum-2.js
function sum(a, b) {
return a + b;
}
module.exports = sumES2015 😿
// ./__tests__/test.js
jest.deepUnmock('../src/sum-1');
import sum from '../src/sum-1';
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});// ./src/sum-1.js
import sum from './sum-2';
export default sum;// ./src/sum-2.js
function sum(a, b) {
return a + b;
}
export default sum;adamchainz