Skip to content

Commit 7e57567

Browse files
cpojerFacebook Github Bot 7
authored andcommitted
Fix a bunch of tests and bugs.
Reviewed By: yungsters Differential Revision: D3111574 fb-gh-sync-id: 2be0f916ce2a83dc4cb6c2530ffec3d3c309cba2 fbshipit-source-id: 2be0f916ce2a83dc4cb6c2530ffec3d3c309cba2
1 parent a750e31 commit 7e57567

File tree

2 files changed

+12
-37
lines changed

2 files changed

+12
-37
lines changed

packages/jest-util/lib/formatMessages.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,16 @@ const path = require('path');
1313

1414
const KEEP_TRACE_LINES = 2;
1515
// filter for noisy stack trace lines
16-
const STACK_TRACE_LINE_IGNORE_RE = new RegExp([
17-
'^timers.js$',
18-
'^' + path.resolve(__dirname, '..', 'lib', 'moduleMocker.js'),
19-
'^' + path.resolve(__dirname, '..', '..', 'vendor', 'jasmine'),
20-
].join('|'));
16+
const STACK_TRACE_LINE_IGNORE_RE =
17+
/^\s+at.*?jest(-cli)?\/(vendor|src|node_modules|packages)\//;
2118

2219
function cleanStackTrace(stackTrace) {
2320
let lines = 0;
24-
const keepFirstLines = () => (lines++ < KEEP_TRACE_LINES);
25-
return stackTrace.split('\n').filter(line => (
26-
keepFirstLines() ||
27-
!/^\s+at.*?jest(-cli)?\/(vendor|src|node_modules)\//.test(line)
28-
)).join('\n');
21+
return stackTrace.split('\n')
22+
.filter(line =>
23+
(lines++ < KEEP_TRACE_LINES) || !STACK_TRACE_LINE_IGNORE_RE.test(line)
24+
)
25+
.join('\n');
2926
}
3027

3128
function formatFailureMessage(testResult, config) {
@@ -60,11 +57,12 @@ function formatFailureMessage(testResult, config) {
6057
return line;
6158
}
6259
}
63-
var filePath = matches[2];
6460
// Filter out noisy and unhelpful lines from the stack trace.
65-
if (STACK_TRACE_LINE_IGNORE_RE.test(filePath)) {
61+
if (STACK_TRACE_LINE_IGNORE_RE.test(line)) {
6662
return null;
6763
}
64+
65+
const filePath = matches[2];
6866
return (
6967
matches[1] +
7068
path.relative(rootDir, filePath) +

src/lib/formatTestResults.js

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const utils = require('jest-util');
1212
const formatResult = (testResult, codeCoverageFormatter, reporter) => {
1313
const output = {
1414
name: testResult.testFilePath,
15-
summary: '', // TODO
15+
summary: '',
1616
message: '',
1717
};
1818

@@ -32,37 +32,14 @@ const formatResult = (testResult, codeCoverageFormatter, reporter) => {
3232

3333
if (!allTestsPassed) {
3434
output.message = utils.formatFailureMessage(testResult, {
35-
rootPath: '',
36-
useColor: false,
35+
rootDir: '',
3736
});
3837
}
3938
}
4039

4140
return output;
4241
};
4342

44-
/**
45-
* @callback codeCoverageFormatter
46-
* @param {*} results
47-
* @param {*} reporter - an instance of the testReporter
48-
*/
49-
50-
/**
51-
* Formats the test results.
52-
* @param {*} results - a results hash determined by the reporter
53-
* @param {codeCoverageFormatter} codeCoverageFormatter
54-
* @param {*} reporter - an instance of the testReporter
55-
* @returns {{success: *, startTime: (*|number|Number),
56-
* numTotalTests: *,
57-
* numTotalTestSuites: *,
58-
* numRuntimeErrorTestSuites: *,
59-
* numPassedTests: *,
60-
* numFailedTests: *,
61-
* numPendingTests: *,
62-
* testResults: (*|{}|Array),
63-
* postSuiteHeaders: *}}
64-
*/
65-
6643
function formatTestResults(results, codeCoverageFormatter, reporter) {
6744
if (!codeCoverageFormatter) {
6845
codeCoverageFormatter = coverage => coverage;

0 commit comments

Comments
 (0)