Skip to content

Commit

Permalink
fixes bug with enableAutomock when automock is set to false (#3624)
Browse files Browse the repository at this point in the history
  • Loading branch information
HurricaneJames authored and cpojer committed Jun 1, 2017
1 parent 0215b67 commit 87fb8ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,20 @@ it('automocking is disabled by default', () =>
expect(exports.setModuleStateValue._isMockFunction).toBe(undefined);
}),
);

it('unmocks modules in config.unmockedModulePathPatterns for tests with automock enabled when automock is false', () =>
createRuntime(__filename, {
automock: false,
moduleNameMapper,
unmockedModulePathPatterns: ['npm3-main-dep'],
}).then(runtime => {
const root = runtime.requireModule(runtime.__mockRootPath);
root.jest.enableAutomock();
const nodeModule = runtime.requireModuleOrMock(
runtime.__mockRootPath,
'npm3-main-dep',
);
const moduleData = nodeModule();
expect(moduleData.isUnmocked()).toBe(true);
})
);
1 change: 0 additions & 1 deletion packages/jest-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class Runtime {
this._unmockList = unmockRegExpCache.get(config);
if (
!this._unmockList &&
config.automock &&
config.unmockedModulePathPatterns
) {
this._unmockList =
Expand Down

0 comments on commit 87fb8ad

Please sign in to comment.