Skip to content

Commit a344d49

Browse files
jseminckcpojer
authored andcommitted
Make listTests always print to console.log (#4391)
* Make listTests always print to console.log * Update snapshot * Update snapshot a second time * Try to remove EOL splitting * Re-add normalize paths * Also update snapshot * Split by \n instead of EOL
1 parent de74b38 commit a344d49

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

integration_tests/__tests__/__snapshots__/list_tests.test.js.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`--listTests flag causes tests to be printed in different lines 1`] = `
4-
"/MOCK_ABOLUTE_PATH/integration_tests/list_tests/__tests__/dummy.test.js
4+
"
5+
/MOCK_ABOLUTE_PATH/integration_tests/list_tests/__tests__/dummy.test.js
56
/MOCK_ABOLUTE_PATH/integration_tests/list_tests/__tests__/other.test.js"
67
`;
78

integration_tests/__tests__/list_tests.test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
const runJest = require('../runJest');
1313
const path = require('path');
14-
const {EOL} = require('os');
1514

1615
const testRootDir = path.resolve(__dirname, '..', '..');
1716

@@ -28,17 +27,17 @@ describe('--listTests flag', () => {
2827

2928
expect(status).toBe(0);
3029
expect(
31-
normalizePaths(stdout).split(EOL).sort().join(EOL),
30+
normalizePaths(stdout).split('\n').sort().join('\n'),
3231
).toMatchSnapshot();
3332
});
3433

3534
it('causes tests to be printed out as JSON when using the --json flag', () => {
36-
const {status, stderr} = runJest('list_tests', ['--listTests', '--json']);
35+
const {status, stdout} = runJest('list_tests', ['--listTests', '--json']);
3736

3837
expect(status).toBe(0);
39-
expect(() => JSON.parse(stderr)).not.toThrow();
38+
expect(() => JSON.parse(stdout)).not.toThrow();
4039
expect(
41-
JSON.stringify(JSON.parse(stderr).map(normalizePaths).sort()),
40+
JSON.stringify(JSON.parse(stdout).map(normalizePaths).sort()),
4241
).toMatchSnapshot();
4342
});
4443
});

packages/jest-cli/src/run_jest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ const runJest = async ({
116116
if (globalConfig.listTests) {
117117
const testsPaths = allTests.map(test => test.path);
118118
if (globalConfig.json) {
119-
outputStream.write(JSON.stringify(testsPaths));
119+
console.log(JSON.stringify(testsPaths));
120120
} else {
121-
outputStream.write(testsPaths.join('\n'));
121+
console.log(testsPaths.join('\n'));
122122
}
123123

124124
onComplete && onComplete(makeEmptyAggregatedTestResult());

0 commit comments

Comments
 (0)