Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test for invalid preset json
  • Loading branch information
xjlim committed Oct 26, 2017
commit 4d2fcf6ea671aedefa1d9f8bfd57f8380f096adb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ exports[`Upgrade help logs a warning when \`scriptPreprocessor\` and/or \`prepro
<yellow></>"
`;

exports[`preset throws when preset is invalid 1`] = `
"<red><bold><bold>● <bold>Validation Error</>:</>
<red></>
<red> Preset <bold>react-native</> is invalid:</>
<red> Unexpected token } in JSON at position 104</>
<red></>
<red> <bold>Configuration Documentation:</></>
<red> https://facebook.github.io/jest/docs/configuration.html</>
<red></>"
`;

exports[`preset throws when preset not found 1`] = `
"<red><bold><bold>● <bold>Validation Error</>:</>
<red></>
Expand Down
7 changes: 7 additions & 0 deletions packages/jest-config/src/__tests__/jest-preset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"moduleNameMapper": {
"b": "b"
},
"modulePathIgnorePatterns": ["b"],
"setupFiles": ["b"],
}
16 changes: 16 additions & 0 deletions packages/jest-config/src/__tests__/normalize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,22 @@ describe('preset', () => {
}).toThrowErrorMatchingSnapshot();
});

test('throws when preset is invalid', () => {
jest.mock('/node_modules/react-native/jest-preset.json', () =>
require.requireActual('./jest-preset.json'),
);

expect(() => {
normalize(
{
preset: 'react-native',
rootDir: '/root/path/foo',
},
{},
);
}).toThrowErrorMatchingSnapshot();
});

test('works with "react-native"', () => {
expect(() => {
normalize(
Expand Down