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 snapshot test
  • Loading branch information
kdnakt committed Jan 26, 2018
commit 8f99c3e879fa4ed9fdfde5163a256626b153099e
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`npm test 1`] = `
"<bold>Snapshot Summary</>
<bold><red> › 2 snapshot tests</></> failed in 1 test suite. <dim>Inspect your code changes or run \`npm test -- -u\` to update them.</>
"
`;

exports[`yarn test 1`] = `
"<bold>Snapshot Summary</>
<bold><red> › 2 snapshot tests</></> failed in 1 test suite. <dim>Inspect your code changes or run \`yarn test -u\` to update them.</>
"
`;
12 changes: 2 additions & 10 deletions packages/jest-cli/src/reporters/__tests__/summary_reporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,12 @@ test('npm test', () => {
process.stderr.write = result => results.push(result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already done in beforeEach

const testReporter = new SummaryReporter(globalConfig);
testReporter.onRunComplete(new Set(), aggregatedResults);
expect(results[0]).toMatch('\u001b[1mSnapshot Summary\u001b[22m');
expect(results[1]).toMatch(
'\u001b[1m\u001b[31m › 2 snapshot tests\u001b[39m\u001b[22m failed in 1 test suite. ' +
'\u001b[2mInspect your code changes or run `npm test -- -u` to update them.\u001b[22m',
);
expect(results[0] + results[1]).toMatchSnapshot();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about results.join('')?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems nice idea.

});

test('yarn test', () => {
process.env.npm_config_user_agent = 'yarn';
const testReporter = new SummaryReporter(globalConfig);
testReporter.onRunComplete(new Set(), aggregatedResults);
expect(results[0]).toMatch('\u001b[1mSnapshot Summary\u001b[22m');
expect(results[1]).toMatch(
'\u001b[1m\u001b[31m › 2 snapshot tests\u001b[39m\u001b[22m failed in 1 test suite. ' +
'\u001b[2mInspect your code changes or run `yarn test -u` to update them.\u001b[22m',
);
expect(results[0] + results[1]).toMatchSnapshot();
});