Skip to content

Commit

Permalink
Make the v8 core module work in Jest. (jestjs#2301)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer authored Dec 12, 2016
1 parent 17bfaa9 commit 3239fc4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions integration_tests/__tests__/require-v8-module-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails oncall+jsinfra
*/

test('v8 module', () => {
expect(() => require('v8')).not.toThrow();

expect(require('v8').getHeapStatistics().total_heap_size).toBeDefined();
});
8 changes: 7 additions & 1 deletion packages/jest-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ class Resolver {
}

isCoreModule(moduleName: string): boolean {
return this._options.hasCoreModules && resolve.isCore(moduleName);
return (
this._options.hasCoreModules &&
(
resolve.isCore(moduleName) ||
moduleName === 'v8'
)
);
}

getModule(name: string): ?Path {
Expand Down

0 comments on commit 3239fc4

Please sign in to comment.