Skip to content

Commit

Permalink
Update package.json to remove a Jest warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Sep 29, 2016
1 parent 2cdf68c commit ff3a1a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"jest": {
"modulePathIgnorePatterns": [
"examples/.*",
"packages/.*/build"
"packages/.*/build",
"packages/jest-runtime/src/__tests__/test_root_with_dup_mocks"
],
"collectCoverageFrom": [
"**/packages/{jest-runtime,jest-matchers,jest-haste-map,jest-file-exists,jest-diff,jest-changed-files}/**/*.js",
Expand All @@ -67,9 +68,9 @@
"testPathIgnorePatterns": [
"/node_modules/",
"/examples/",
"integration_tests/.*/__tests__",
"/integration_tests/.*/__tests__",
"\\.snap$",
"packages/.*/build"
"/packages/.*/build"
],
"testRegex": ".*-test\\.js"
}
Expand Down
15 changes: 11 additions & 4 deletions packages/jest-runtime/src/__tests__/Runtime-requireMock-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@
const path = require('path');

let createRuntime;
const consoleWarn = console.warn;

describe('Runtime', () => {

beforeEach(() => {
createRuntime = require('createRuntime');
});

afterEach(() => {
console.warn = consoleWarn;
});

describe('requireMock', () => {
it('uses manual mocks before attempting to automock', () =>
createRuntime(__filename).then(runtime => {
Expand Down Expand Up @@ -151,11 +156,13 @@ describe('Runtime', () => {
}),
);

it('uses the closest manual mock when duplicates exist', () =>
createRuntime(__filename, {
it('uses the closest manual mock when duplicates exist', () => {
console.warn = jest.fn();
return createRuntime(__filename, {
rootDir:
path.resolve(path.dirname(__filename), 'test_root_with_dup_mocks'),
}).then(runtime => {
expect(console.warn).toBeCalled();
const exports1 = runtime.requireMock(
runtime.__mockRootPath,
'./subdir1/MyModule',
Expand All @@ -171,7 +178,7 @@ describe('Runtime', () => {
expect(exports2.modulePath).toEqual(
'subdir2/__mocks__/MyModule.js',
);
}),
);
});
});
});
});

0 comments on commit ff3a1a7

Please sign in to comment.