Skip to content

Commit

Permalink
Add displayName to MPR (#4327)
Browse files Browse the repository at this point in the history
* Modify flow types to support displayName

* Add project displayName

* Some small fixes

* Add tests

* Fix eslint

* Better handling for non interactive terminals

* Update tests

* Use supportColor
  • Loading branch information
rogeliog authored and cpojer committed Aug 27, 2017
1 parent 39f83a9 commit e535665
Show file tree
Hide file tree
Showing 26 changed files with 152 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`console printing 1`] = `
" PASS __tests__/console.test.js
"PASS __tests__/console.test.js
● Console
console.log __tests__/console.test.js:11
Expand Down Expand Up @@ -43,7 +43,7 @@ exports[`console printing with --verbose 1`] = `
`;
exports[`console printing with --verbose 2`] = `
" PASS __tests__/console.test.js
"PASS __tests__/console.test.js
✓ works just fine
"
Expand All @@ -61,7 +61,7 @@ Ran all test suites.
exports[`does not print to console with --silent 1`] = `""`;
exports[`does not print to console with --silent 2`] = `
" PASS __tests__/console.test.js
"PASS __tests__/console.test.js
"
`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`prints console.logs when run with forceExit 1`] = `
" PASS __tests__/a-banana.js
"PASS __tests__/a-banana.js
✓ banana
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Object {
`;

exports[`Custom Reporters Integration default reporters enabled 1`] = `
" PASS __tests__/add.test.js
"PASS __tests__/add.test.js
Custom Reporters
✓ adds ok
Expand Down
10 changes: 5 additions & 5 deletions integration_tests/__tests__/__snapshots__/failures.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`not throwing Error objects 1`] = `
" FAIL __tests__/throw_number.test.js
"FAIL __tests__/throw_number.test.js
● Test suite failed to run
Expected an Error, but \\"1\\" was thrown
Expand All @@ -10,7 +10,7 @@ exports[`not throwing Error objects 1`] = `
`;

exports[`not throwing Error objects 2`] = `
" FAIL __tests__/throw_string.test.js
"FAIL __tests__/throw_string.test.js
● Test suite failed to run
Error
Expand All @@ -20,7 +20,7 @@ exports[`not throwing Error objects 2`] = `
`;

exports[`not throwing Error objects 3`] = `
" FAIL __tests__/throw_object.test.js
"FAIL __tests__/throw_object.test.js
● Test suite failed to run
Error: No message was provided
Expand All @@ -29,7 +29,7 @@ exports[`not throwing Error objects 3`] = `
`;

exports[`not throwing Error objects 4`] = `
" FAIL __tests__/assertion_count.test.js
"FAIL __tests__/assertion_count.test.js
● .assertions() › throws
expect(received).toBeTruthy()
Expected value to be truthy, instead received
Expand Down Expand Up @@ -59,7 +59,7 @@ exports[`not throwing Error objects 4`] = `
`;

exports[`works with node assert 1`] = `
" FAIL __tests__/node_assertion_error.test.js
"FAIL __tests__/node_assertion_error.test.js
● assert
assert.equal(received, expected) or assert(received)
Expand Down
14 changes: 7 additions & 7 deletions integration_tests/__tests__/__snapshots__/globals.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`basic test constructs 1`] = `
" PASS __tests__/basic.test-constructs.test.js
"PASS __tests__/basic.test-constructs.test.js
✓ it
✓ test
describe
Expand All @@ -21,7 +21,7 @@ Ran all test suites.
`;
exports[`only 1`] = `
" PASS __tests__/only-constructs.test.js
"PASS __tests__/only-constructs.test.js
✓ test.only
✓ it.only
✓ fit
Expand All @@ -47,7 +47,7 @@ Ran all test suites.
`;
exports[`only with expand arg 1`] = `
" PASS __tests__/only-constructs.test.js
"PASS __tests__/only-constructs.test.js
○ it
✓ test.only
✓ it.only
Expand All @@ -73,7 +73,7 @@ Ran all test suites.
`;
exports[`skips 1`] = `
" PASS __tests__/skips-constructs.test.js
"PASS __tests__/skips-constructs.test.js
✓ it
○ skipped 4 tests
xdescribe
Expand All @@ -96,7 +96,7 @@ Ran all test suites.
`;
exports[`skips with expand arg 1`] = `
" PASS __tests__/skips-constructs.test.js
"PASS __tests__/skips-constructs.test.js
✓ it
○ xtest
○ xit
Expand All @@ -123,7 +123,7 @@ Ran all test suites.
`;
exports[`tests with no implementation 1`] = `
" PASS __tests__/only-constructs.test.js
"PASS __tests__/only-constructs.test.js
✓ it
○ skipped 2 tests
Expand All @@ -140,7 +140,7 @@ Ran all test suites.
`;
exports[`tests with no implementation with expand arg 1`] = `
" PASS __tests__/only-constructs.test.js
"PASS __tests__/only-constructs.test.js
✓ it
○ it, no implementation
○ test, no implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`traverses directory tree up until it finds jest.config 1`] = `
`;
exports[`traverses directory tree up until it finds jest.config 2`] = `
" PASS ../../../__tests__/a-banana.js
"PASS ../../../__tests__/a-banana.js
✓ banana
✓ abc
Expand All @@ -25,7 +25,7 @@ Ran all test suites.
`;
exports[`works with jest.conf.js 1`] = `
" PASS __tests__/a-banana.js
"PASS __tests__/a-banana.js
✓ banana
"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`moduleNameMapper correct configuration 1`] = `
" PASS __tests__/index.js
"PASS __tests__/index.js
✓ moduleNameMapping correct configuration
"
`;

exports[`moduleNameMapper wrong configuration 1`] = `
" FAIL __tests__/index.js
"FAIL __tests__/index.js
● Test suite failed to run
Configuration error:
Expand Down
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>>
Expand All @@ -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 project2/__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 project2/__tests__/file1.test.js"
"PASS BACKEND project1/__tests__/file1.test.js
PASS UI project3/__tests__/file1.test.js
PASS project2/__tests__/file1.test.js"
`;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`does not exceed the timeout 1`] = `
" PASS __tests__/a-banana.js
"PASS __tests__/a-banana.js
✓ banana
"
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/__tests__/compare_dom_nodes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ skipOnWindows.suite();
test('does not crash when expect involving a DOM node fails', () => {
const result = runJest('compare-dom-nodes');

expect(result.stderr).toContain('FAIL __tests__/failed-assertion.js');
expect(result.stderr).toContain('FAIL __tests__/failed-assertion.js');
});
2 changes: 1 addition & 1 deletion integration_tests/__tests__/find_related_files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test('runs tests related to filename', () => {
expect(stdout).toMatch(/no tests found/i);

const {stderr} = runJest(DIR, ['--findRelatedTests', 'a.js']);
expect(stderr).toMatch('PASS __tests__/test.test.js');
expect(stderr).toMatch('PASS __tests__/test.test.js');

const summaryMsg = 'Ran all test suites related to files matching /a.js/i.';
expect(stderr).toMatch(summaryMsg);
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/__tests__/jest_require_actual.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ test('understands dependencies using require.requireActual', () => {
({stdout, stderr} = runJest(DIR, ['--findRelatedTests', 'a.js']));

expect(stdout).not.toMatch('No tests found');
expect(stderr).toMatch('PASS __tests__/a.test.js');
expect(stderr).not.toMatch('PASS __tests__/b.test.js');
expect(stderr).toMatch('PASS __tests__/a.test.js');
expect(stderr).not.toMatch('PASS __tests__/b.test.js');

// change to jest.requireActual
writeFiles(DIR, {
Expand All @@ -55,6 +55,6 @@ test('understands dependencies using require.requireActual', () => {

({stderr, stdout} = runJest(DIR, ['--findRelatedTests', 'a.js']));
expect(stdout).not.toMatch('No tests found');
expect(stderr).toMatch('PASS __tests__/a.test.js');
expect(stderr).not.toMatch('PASS __tests__/b.test.js');
expect(stderr).toMatch('PASS __tests__/a.test.js');
expect(stderr).not.toMatch('PASS __tests__/b.test.js');
});
8 changes: 4 additions & 4 deletions integration_tests/__tests__/jest_require_mock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ test('understands dependencies using require.requireMock', () => {
({stdout, stderr} = runJest(DIR, ['--findRelatedTests', 'a.js']));

expect(stdout).not.toMatch('No tests found');
expect(stderr).toMatch('PASS __tests__/a.test.js');
expect(stderr).not.toMatch('PASS __tests__/b.test.js');
expect(stderr).toMatch('PASS __tests__/a.test.js');
expect(stderr).not.toMatch('PASS __tests__/b.test.js');

// change to jest.requireMock
writeFiles(DIR, {
Expand All @@ -55,6 +55,6 @@ test('understands dependencies using require.requireMock', () => {

({stderr, stdout} = runJest(DIR, ['--findRelatedTests', 'a.js']));
expect(stdout).not.toMatch('No tests found');
expect(stderr).toMatch('PASS __tests__/a.test.js');
expect(stderr).not.toMatch('PASS __tests__/b.test.js');
expect(stderr).toMatch('PASS __tests__/a.test.js');
expect(stderr).not.toMatch('PASS __tests__/b.test.js');
});
2 changes: 1 addition & 1 deletion integration_tests/__tests__/log_heap_usage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ test('logs memory usage', () => {
});

const {stderr} = runJest(DIR, ['--logHeapUsage']);
expect(stderr).toMatch(/PASS\s{2}__tests__\/a-banana.js.*\d+ MB heap size/);
expect(stderr).toMatch(/PASS\s__tests__\/a-banana.js.*\d+ MB heap size/);
});
26 changes: 19 additions & 7 deletions integration_tests/__tests__/multi_project_runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ test('can pass projects or global config', () => {
test('file1', () => {});
`,
'project1/file1.js': fileContentWithProvidesModule('file1'),
'project1/jest.config.js': `module.exports = {rootDir: './'}`,
'project1/jest.config.js': `module.exports = {rootDir: './', displayName: 'BACKEND'}`,
'project2/__tests__/file1.test.js': `
const file1 = require('file1');
test('file1', () => {});
`,
'project2/file1.js': fileContentWithProvidesModule('file1'),
'project2/jest.config.js': `module.exports = {rootDir: './'}`,
'project3/__tests__/file1.test.js': `
const file1 = require('file1');
test('file1', () => {});
`,
'project3/file1.js': fileContentWithProvidesModule('file1'),
'project3/jest.config.js': `module.exports = {rootDir: './', displayName: 'UI'}`,
});
let stderr;

Expand All @@ -68,12 +74,18 @@ test('can pass projects or global config', () => {
writeFiles(DIR, {
'global_config.js': `
module.exports = {
projects: ['project1/', 'project2/'],
projects: ['project1/', 'project2/', 'project3/'],
};
`,
});

({stderr} = runJest(DIR, ['-i', '--projects', 'project1', 'project2']));
({stderr} = runJest(DIR, [
'-i',
'--projects',
'project1',
'project2',
'project3',
]));

const result1 = extractSummary(stderr);
expect(result1.summary).toMatchSnapshot();
Expand Down Expand Up @@ -161,8 +173,8 @@ test('resolves projects and their <rootDir> properly', () => {
({stderr} = runJest(DIR));

expect(stderr).toMatch('Ran all test suites in 2 projects.');
expect(stderr).toMatch(' PASS project1/__tests__/test.test.js');
expect(stderr).toMatch(' PASS project2/__tests__/test.test.js');
expect(stderr).toMatch('PASS project1/__tests__/test.test.js');
expect(stderr).toMatch('PASS project2/__tests__/test.test.js');

// Use globs
writeFiles(DIR, {
Expand All @@ -177,8 +189,8 @@ test('resolves projects and their <rootDir> properly', () => {

({stderr} = runJest(DIR));
expect(stderr).toMatch('Ran all test suites in 2 projects.');
expect(stderr).toMatch(' PASS project1/__tests__/test.test.js');
expect(stderr).toMatch(' PASS project2/__tests__/test.test.js');
expect(stderr).toMatch('PASS project1/__tests__/test.test.js');
expect(stderr).toMatch('PASS project2/__tests__/test.test.js');

// Include two projects that will resolve to the same config
writeFiles(DIR, {
Expand Down
Loading

0 comments on commit e535665

Please sign in to comment.