Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@
regardless of order ([#6150](https://github.com/facebook/jest/pull/6150))
* `[pretty-format]` [**BREAKING**] Remove undefined props from React elements
([#6162](https://github.com/facebook/jest/pull/6162))
* `[jest-haste-map]` Properly resolve mocked node modules without package.json
defined ([#6232](https://github.com/facebook/jest/pull/6232))

### Chore & Maintenance

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = 'test mock-module-without-pkg';
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
jest.mock('mock-module');
jest.mock('mock-module-alt');
jest.mock('mock-jsx-module');
jest.mock('mock-module-without-pkg');

it('should resolve entry as index.js when package main is "."', () => {
const mockModule = require('mock-module');
Expand All @@ -25,3 +26,8 @@ it('should resolve entry as index with other configured module file extension wh
const mockJsxModule = require('mock-jsx-module');
expect(mockJsxModule).toEqual('test jsx');
});

it('should resolve entry as index without package.json', () => {
const mockModuleWithoutPkg = require('mock-module-without-pkg');
expect(mockModuleWithoutPkg).toEqual('test mock-module-without-pkg');
});
2 changes: 1 addition & 1 deletion packages/jest-haste-map/src/module_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class ModuleMap {
}

getMockModule(name: string): ?Path {
return this._raw.mocks[name];
return this._raw.mocks[name] || this._raw.mocks[name + '/index'];
}

getRawModuleMap(): RawModuleMap {
Expand Down