Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent reporter + Run failed tests first #1480

Merged
merged 6 commits into from
Sep 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 27 additions & 2 deletions integration_tests/__tests__/__snapshots__/console-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ exports[`test console printing 1`] = `
console.error __tests__/console-test.js:17
This is an error message.

Test Summary
› Ran all tests."

"
`;

exports[`test console printing 2`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`test console printing with --verbose 1`] = `
Expand All @@ -30,3 +39,19 @@ exports[`test console printing with --verbose 1`] = `

"
`;

exports[`test console printing with --verbose 2`] = `
" PASS __tests__/console-test.js
✓ works just fine

"
`;

exports[`test console printing with --verbose 3`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests.
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ All files | 100 | 100 | 100 | 100 | |
`;

exports[`test json reporter printing with --coverage 1`] = `
"Coverage Summary (add \"text\" to the \"coverageReporters\" setting to receive a full report)
› Statements: 100%
› Branches: 100%
› Lines: 100%
› Functions: 100%

Test Summary
› Ran all tests."
"Test Suites: 1 failed, 0 passed, 1 total
Tests: 1 failed, 1 passed, 2 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`test outputs coverage report 1`] = `
Expand Down
45 changes: 30 additions & 15 deletions integration_tests/__tests__/__snapshots__/failures-test.js.snap
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
exports[`test throwing not Error objects 1`] = `
" FAIL __tests__/throw-number-test.js
Object {
"rest": " FAIL __tests__/throw-number-test.js
● Test suite failed to run

Expected an Error, but \"1\" was thrown


Test Summary
› Ran all tests matching \"throw-number-test.js\".
› 1 test suite failed, 0 tests passed (0 total in 1 test suite, <TIME>)
"
",
"summary": "Test Suites: 1 failed, 0 passed, 1 total
Tests: 0 passed, 0 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests matching \"throw-number-test.js\".
",
}
`;

exports[`test throwing not Error objects 2`] = `
" FAIL __tests__/throw-string-test.js
Object {
"rest": " FAIL __tests__/throw-string-test.js
● Test suite failed to run

Error
banana

Test Summary
› Ran all tests matching \"throw-string-test.js\".
› 1 test suite failed, 0 tests passed (0 total in 1 test suite, <TIME>)
"
",
"summary": "Test Suites: 1 failed, 0 passed, 1 total
Tests: 0 passed, 0 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests matching \"throw-string-test.js\".
",
}
`;

exports[`test throwing not Error objects 3`] = `
" FAIL __tests__/throw-object-test.js
Object {
"rest": " FAIL __tests__/throw-object-test.js
● Test suite failed to run

Error: No message was provided

Test Summary
› Ran all tests matching \"throw-object-test.js\".
› 1 test suite failed, 0 tests passed (0 total in 1 test suite, <TIME>)
"
",
"summary": "Test Suites: 1 failed, 0 passed, 1 total
Tests: 0 passed, 0 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests matching \"throw-object-test.js\".
",
}
`;
48 changes: 40 additions & 8 deletions integration_tests/__tests__/__snapshots__/globals-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ exports[`test basic test constructs 1`] = `
✓ it
✓ test

Test Summary
› Ran all tests."
"
`;

exports[`test basic test constructs 2`] = `
"Test Suites: 1 passed, 1 total
Tests: 4 passed, 4 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`test only 1`] = `
Expand All @@ -24,8 +32,16 @@ exports[`test only 1`] = `
describe
✓ test

Test Summary
› Ran all tests."
"
`;

exports[`test only 2`] = `
"Test Suites: 1 passed, 1 total
Tests: 7 passed, 8 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`test skips 1`] = `
Expand All @@ -43,8 +59,16 @@ exports[`test skips 1`] = `
describe
○ test

Test Summary
› Ran all tests."
"
`;

exports[`test skips 2`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 9 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`test tests with no implementation 1`] = `
Expand All @@ -53,6 +77,14 @@ exports[`test tests with no implementation 1`] = `
○ it, no implementation
○ test, no implementation

Test Summary
› Ran all tests."
"
`;

exports[`test tests with no implementation 2`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 3 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests.
"
`;
89 changes: 89 additions & 0 deletions integration_tests/__tests__/__snapshots__/snapshot-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
exports[`Snapshot Validation deletes a snapshot when a test does removes all the snapshots 1`] = `
"Test Suites: 3 passed, 3 total
Tests: 7 passed, 7 total
Snapshots: 7 added, 0 passed, 7 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`Snapshot Validation deletes a snapshot when a test does removes all the snapshots 2`] = `
"Test Suites: 3 passed, 3 total
Tests: 5 passed, 5 total
Snapshots: 4 passed, 4 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`Snapshot Validation deletes the snapshot if the test file has been removed 1`] = `
"Test Suites: 3 passed, 3 total
Tests: 7 passed, 7 total
Snapshots: 7 added, 0 passed, 7 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`Snapshot Validation deletes the snapshot if the test file has been removed 2`] = `
"Test Suites: 2 passed, 2 total
Tests: 4 passed, 4 total
Snapshots: 4 passed, 4 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`Snapshot Validation updates the snapshot when a test removes some snapshots 1`] = `
"Test Suites: 3 passed, 3 total
Tests: 7 passed, 7 total
Snapshots: 7 added, 0 passed, 7 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`Snapshot Validation updates the snapshot when a test removes some snapshots 2`] = `
"Test Suites: 3 passed, 3 total
Tests: 7 passed, 7 total
Snapshots: 1 updated, 5 passed, 6 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`Snapshot works as expected 1`] = `
"Test Suites: 2 passed, 2 total
Tests: 4 passed, 4 total
Snapshots: 4 added, 0 passed, 4 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`Snapshot works with escaped characters 1`] = `
"Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 1 added, 0 passed, 1 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`Snapshot works with escaped characters 2`] = `
"Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 1 added, 1 passed, 2 total
Time: <<REPLACED>>
Ran all tests.
"
`;

exports[`Snapshot works with escaped characters 3`] = `
"Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 2 passed, 2 total
Time: <<REPLACED>>
Ran all tests.
"
`;
53 changes: 53 additions & 0 deletions integration_tests/__tests__/__snapshots__/stack_trace-test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
exports[`Stack Trace does not print a stack trace for errors when --noStackTrace is given 1`] = `
"Test Suites: 1 failed, 0 passed, 1 total
Tests: 3 failed, 0 passed, 3 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests matching \"test-error-test.js\".
"
`;

exports[`Stack Trace does not print a stack trace for matching errors when --noStackTrace is given 1`] = `
"Test Suites: 1 failed, 0 passed, 1 total
Tests: 1 failed, 0 passed, 1 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests matching \"stack-trace-test.js\".
"
`;

exports[`Stack Trace does not print a stack trace for runtime errors when --noStackTrace is given 1`] = `
"Test Suites: 1 failed, 0 passed, 1 total
Tests: 0 passed, 0 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests matching \"runtime-error-test.js\".
"
`;

exports[`Stack Trace prints a stack trace for errors 1`] = `
"Test Suites: 1 failed, 0 passed, 1 total
Tests: 3 failed, 0 passed, 3 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests matching \"test-error-test.js\".
"
`;

exports[`Stack Trace prints a stack trace for matching errors 1`] = `
"Test Suites: 1 failed, 0 passed, 1 total
Tests: 1 failed, 0 passed, 1 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests matching \"stack-trace-test.js\".
"
`;

exports[`Stack Trace prints a stack trace for runtime errors 1`] = `
"Test Suites: 1 failed, 0 passed, 1 total
Tests: 0 passed, 0 total
Snapshots: 0 passed, 0 total
Time: <<REPLACED>>
Ran all tests matching \"runtime-error-test.js\".
"
`;
23 changes: 12 additions & 11 deletions integration_tests/__tests__/console-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,26 @@

const runJest = require('../runJest');
const skipOnWindows = require('skipOnWindows');
const {extractSummary} = require('../utils');

skipOnWindows.suite();

test('console printing', () => {
const result = runJest('console');
const stderr = result.stderr.toString();
const {stderr, status} = runJest('console');
const {summary, rest} = extractSummary(stderr);

expect(result.status).toBe(0);

// Remove last two lines because they contain timing information.
const output = stderr.split('\n').slice(0, -2).join('\n');
expect(output).toMatchSnapshot();
expect(status).toBe(0);
expect(rest).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});

test('console printing with --verbose', () => {
const result = runJest('console', ['--verbose', '--no-cache']);
const stdout = result.stdout.toString();

expect(result.status).toBe(0);
const {stderr, stdout, status} =
runJest('console', ['--verbose', '--no-cache']);
const {summary, rest} = extractSummary(stderr);

expect(status).toBe(0);
expect(stdout).toMatchSnapshot();
expect(rest).toMatchSnapshot();
expect(summary).toMatchSnapshot();
});
Loading