-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add displayName to MPR #4327
Add displayName to MPR #4327
Changes from 6 commits
84d73c7
372a1bb
417416a
a6ae265
1192760
27a07dc
dc72c42
1084ae9
1f6f3df
fdb0d1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`can pass projects or global config 1`] = ` | ||
"Test Suites: 2 failed, 2 total | ||
"Test Suites: 3 failed, 3 total | ||
Tests: 0 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
|
@@ -10,29 +10,31 @@ Ran all test suites. | |
`; | ||
|
||
exports[`can pass projects or global config 2`] = ` | ||
"Test Suites: 2 passed, 2 total | ||
Tests: 2 passed, 2 total | ||
"Test Suites: 3 passed, 3 total | ||
Tests: 3 passed, 3 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites in 2 projects. | ||
Ran all test suites in 3 projects. | ||
" | ||
`; | ||
|
||
exports[`can pass projects or global config 3`] = ` | ||
"PASS project1/__tests__/file1.test.js | ||
"PASS BACKEND project1/__tests__/file1.test.js | ||
PASS UI project3/__tests__/file1.test.js | ||
PASS project2/__tests__/file1.test.js" | ||
`; | ||
|
||
exports[`can pass projects or global config 4`] = ` | ||
"Test Suites: 2 passed, 2 total | ||
Tests: 2 passed, 2 total | ||
"Test Suites: 3 passed, 3 total | ||
Tests: 3 passed, 3 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites in 2 projects. | ||
Ran all test suites in 3 projects. | ||
" | ||
`; | ||
|
||
exports[`can pass projects or global config 5`] = ` | ||
"PASS project1/__tests__/file1.test.js | ||
"PASS BACKEND project1/__tests__/file1.test.js | ||
PASS UI project3/__tests__/file1.test.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is probably going to fail when they're executed in different order. Previous test had identical lines (: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohh, now I get this change that @thymikee was making for snapshots. Can we merge that one for the next alpha release? We can break the snapshot format for 21, and update the snapshot version. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah! i'll rerecord snapshots in www There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a mechanism to have multiple versions of snapshots at the same time? i remember we had this idea somewhere There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should be able to decouple snapshot format changes from jest as a framework changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not the right place to have this conversation, I commented here: #4183 (comment) cc @thymikee There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aaronabramov Should it be fine because it is using |
||
PASS project2/__tests__/file1.test.js" | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,19 +8,23 @@ | |
* @flow | ||
*/ | ||
|
||
import type {Path} from 'types/Config'; | ||
import type {GlobalConfig, ProjectConfig} from 'types/Config'; | ||
import type {TestResult} from 'types/TestResult'; | ||
|
||
import chalk from 'chalk'; | ||
import {formatTestPath} from './utils'; | ||
import {formatTestPath, printDisplayName} from './utils'; | ||
|
||
const LONG_TEST_COLOR = chalk.reset.bold.bgRed; | ||
// Explicitly reset for these messages since they can get written out in the | ||
// middle of error logging | ||
const FAIL = chalk.reset.inverse.bold.red(' FAIL '); | ||
const PASS = chalk.reset.inverse.bold.green(' PASS '); | ||
|
||
module.exports = (result: TestResult, config: {rootDir: Path}) => { | ||
module.exports = ( | ||
result: TestResult, | ||
globalConfig: GlobalConfig, | ||
projectConfig?: ProjectConfig, | ||
) => { | ||
const testPath = result.testFilePath; | ||
const status = | ||
result.numFailingTests > 0 || result.testExecError ? FAIL : PASS; | ||
|
@@ -39,8 +43,15 @@ module.exports = (result: TestResult, config: {rootDir: Path}) => { | |
testDetail.push(`${toMB(result.memoryUsage)} MB heap size`); | ||
} | ||
|
||
const projectDisplayName = | ||
projectConfig && projectConfig.displayName | ||
? printDisplayName(projectConfig) + ' ' | ||
: ''; | ||
|
||
return ( | ||
`${status} ${formatTestPath(config, testPath)}` + | ||
(testDetail.length ? ` (${testDetail.join(', ')})` : '') | ||
`${status} ${projectDisplayName}${formatTestPath( | ||
projectConfig ? projectConfig : globalConfig, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm a little worried about that. Is this for resolving the relative test path? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, but the behavior here should not change with this PR |
||
testPath, | ||
)}` + (testDetail.length ? ` (${testDetail.join(', ')})` : '') | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaronabramov There is a double space here... this happens in cases where we disable
chalk
... because we are doingShould we remove those extra spaces when chalk is disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's remove it in that case. Both on the left and right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that only the
displayName
had the extra spaces but it seems thatPASS
/FAIL
also have them already in master... so the fix might involve a bit more changesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the diff for removing the extra spaces in
PASS
andFAIL
rogeliog/jest@add-display-name...rogeliog:add-display-name-full-diff (Still need some work to make sure it works withCI=true jest --color
)@cpojer @aaronabramov I'm not sure if that leading space before PASS and the two after it are intentionally there in the current version or if it is fine to remove them? I'm fine with either I just wanted to understand if any of these current behavior was intentional... I'll update this PR after I get a better understanding on the expected behavior of non interactive non MPR output :) thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to remove them when colors are disabled.