Skip to content

Commit 9fed66e

Browse files
HurricaneJamescpojer
authored andcommittedMay 23, 2017
fixes bug with enableAutomock when automock is set to false (#3624)
1 parent f8bbdbb commit 9fed66e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
 

‎packages/jest-runtime/src/__tests__/Runtime-requireModuleOrMock-test.js

+15
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,18 @@ it('automocking is disabled by default', () =>
160160
);
161161
expect(exports.setModuleStateValue._isMockFunction).toBe(undefined);
162162
}));
163+
164+
it('unmocks modules in config.unmockedModulePathPatterns for tests with automock enabled when automock is false', () =>
165+
createRuntime(__filename, {
166+
automock: false,
167+
moduleNameMapper,
168+
unmockedModulePathPatterns: ['npm3-main-dep'],
169+
}).then(runtime => {
170+
const root = runtime.requireModule(runtime.__mockRootPath);
171+
root.jest.enableAutomock();
172+
const nodeModule = runtime.requireModuleOrMock(runtime.__mockRootPath, 'npm3-main-dep');
173+
const moduleData = nodeModule();
174+
expect(moduleData.isUnmocked()).toBe(true);
175+
})
176+
);
177+

‎packages/jest-runtime/src/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ class Runtime {
146146
this._unmockList = unmockRegExpCache.get(config);
147147
if (
148148
!this._unmockList &&
149-
config.automock &&
150149
config.unmockedModulePathPatterns
151150
) {
152151
this._unmockList = new RegExp(

0 commit comments

Comments
 (0)
Please sign in to comment.