Skip to content

Commit

Permalink
Don't local require perttier in jest-jasmine2
Browse files Browse the repository at this point in the history
  • Loading branch information
tryggvigy committed Jul 29, 2018
1 parent 7caef39 commit ba542f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions e2e/__tests__/to_match_inline_snapshot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,20 @@ test('supports async tests', () => {
expect(status).toBe(0);
expect(fileAfter).toMatchSnapshot();
});

// issue: https://github.com/facebook/jest/issues/6702
test('handles mocking native modules prettier relies on', () => {
const filename = 'mockFail.test.js';
const test = `
jest.mock('path', () => ({}));
jest.mock('fs', () => ({}));
test('inline snapshots', () => {
expect({}).toMatchInlineSnapshot();
});
`;

writeFiles(TESTS_DIR, {[filename]: test});
const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false', filename]);
expect(stderr).toMatch('1 snapshot written from 1 test suite.');
expect(status).toBe(0);
});
3 changes: 2 additions & 1 deletion packages/jest-jasmine2/src/setup_jest_globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export default ({
expand,
getBabelTraverse: () => require('babel-traverse').default,
getPrettier: () =>
config.prettierPath ? localRequire(config.prettierPath) : null,
// $FlowFixMe dynamic require
config.prettierPath ? require(config.prettierPath) : null,
updateSnapshot,
});
setState({snapshotState, testPath});
Expand Down

0 comments on commit ba542f4

Please sign in to comment.