-
-
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 5 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(', ')})` : '') | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ export type HasteConfig = {| | |
defaultPlatform?: ?string, | ||
hasteImplModulePath?: string, | ||
platforms?: Array<string>, | ||
providesModuleNodeModules: Array<string>, | ||
providesModuleNodeModules: Array<string> | ||
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. what happened to the formatting? 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 was about to add that comment... this is what my Prettier config is formatting this file to... I'll double check if I have something wrong on my setup |
||
|}; | ||
|
||
export type ReporterConfig = [string, Object]; | ||
|
@@ -37,7 +37,7 @@ export type DefaultOptions = {| | |
mapCoverage: boolean, | ||
moduleDirectories: Array<string>, | ||
moduleFileExtensions: Array<string>, | ||
moduleNameMapper: {[key: string]: string}, | ||
moduleNameMapper: { [key: string]: string }, | ||
modulePathIgnorePatterns: Array<string>, | ||
noStackTrace: boolean, | ||
notify: boolean, | ||
|
@@ -58,7 +58,7 @@ export type DefaultOptions = {| | |
useStderr: boolean, | ||
verbose: ?boolean, | ||
watch: boolean, | ||
watchman: boolean, | ||
watchman: boolean | ||
|}; | ||
|
||
export type InitialOptions = { | ||
|
@@ -71,11 +71,12 @@ export type InitialOptions = { | |
changedFilesWithAncestor?: boolean, | ||
collectCoverage?: boolean, | ||
collectCoverageFrom?: Array<Glob>, | ||
collectCoverageOnlyFrom?: {[key: string]: boolean}, | ||
collectCoverageOnlyFrom?: { [key: string]: boolean }, | ||
coverageDirectory?: string, | ||
coveragePathIgnorePatterns?: Array<string>, | ||
coverageReporters?: Array<string>, | ||
coverageThreshold?: {global: {[key: string]: number}}, | ||
coverageThreshold?: { global: { [key: string]: number } }, | ||
displayName?: string, | ||
expand?: boolean, | ||
findRelatedTests?: boolean, | ||
forceExit?: boolean, | ||
|
@@ -89,7 +90,7 @@ export type InitialOptions = { | |
moduleDirectories?: Array<string>, | ||
moduleFileExtensions?: Array<string>, | ||
moduleLoader?: Path, | ||
moduleNameMapper?: {[key: string]: string}, | ||
moduleNameMapper?: { [key: string]: string }, | ||
modulePathIgnorePatterns?: Array<string>, | ||
modulePaths?: Array<string>, | ||
name?: string, | ||
|
@@ -124,15 +125,15 @@ export type InitialOptions = { | |
testRunner?: string, | ||
testURL?: string, | ||
timers?: 'real' | 'fake', | ||
transform?: {[key: string]: string}, | ||
transform?: { [key: string]: string }, | ||
transformIgnorePatterns?: Array<Glob>, | ||
unmockedModulePathPatterns?: Array<string>, | ||
updateSnapshot?: boolean, | ||
useStderr?: boolean, | ||
verbose?: ?boolean, | ||
watch?: boolean, | ||
watchAll?: boolean, | ||
watchman?: boolean, | ||
watchman?: boolean | ||
}; | ||
|
||
export type SnapshotUpdateState = 'all' | 'new' | 'none'; | ||
|
@@ -142,10 +143,10 @@ export type GlobalConfig = {| | |
changedFilesWithAncestor: boolean, | ||
collectCoverage: boolean, | ||
collectCoverageFrom: Array<Glob>, | ||
collectCoverageOnlyFrom: ?{[key: string]: boolean}, | ||
collectCoverageOnlyFrom: ?{ [key: string]: boolean }, | ||
coverageDirectory: string, | ||
coverageReporters: Array<string>, | ||
coverageThreshold: {global: {[key: string]: number}}, | ||
coverageThreshold: { global: { [key: string]: number } }, | ||
expand: boolean, | ||
findRelatedTests: boolean, | ||
forceExit: boolean, | ||
|
@@ -175,7 +176,7 @@ export type GlobalConfig = {| | |
verbose: ?boolean, | ||
watch: boolean, | ||
watchAll: boolean, | ||
watchman: boolean, | ||
watchman: boolean | ||
|}; | ||
|
||
export type ProjectConfig = {| | ||
|
@@ -185,6 +186,7 @@ export type ProjectConfig = {| | |
cacheDirectory: Path, | ||
clearMocks: boolean, | ||
coveragePathIgnorePatterns: Array<string>, | ||
displayName: ?string, | ||
globals: ConfigGlobals, | ||
haste: HasteConfig, | ||
moduleDirectories: Array<string>, | ||
|
@@ -213,5 +215,5 @@ export type ProjectConfig = {| | |
timers: 'real' | 'fake', | ||
transform: Array<[string, Path]>, | ||
transformIgnorePatterns: Array<Glob>, | ||
unmockedModulePathPatterns: ?Array<string>, | ||
unmockedModulePathPatterns: ?Array<string> | ||
|}; |
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.