Skip to content
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

Fix regression in BufferedConsole after TS migration #8021

Merged
merged 4 commits into from Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions e2e/__tests__/__snapshots__/console.test.ts.snap
Expand Up @@ -50,6 +50,16 @@ Time: <<REPLACED>>
Ran all test suites.
`;

exports[`does not error out when using winston 1`] = ``;

exports[`does not error out when using winston 2`] = `
Test Suites: 1 failed, 1 passed, 2 of 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: <<REPLACED>>
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`;
Expand Down
19 changes: 19 additions & 0 deletions e2e/__tests__/console.test.ts
Expand Up @@ -59,3 +59,22 @@ test('the jsdom console is the same as the test console', () => {
expect(wrap(rest)).toMatchSnapshot();
expect(wrap(summary)).toMatchSnapshot();
});

test('does not error out when using winston', () => {
const {stderr, stdout, status} = runJest('console-winston');
const {summary, rest} = extractSummary(stderr);

expect(wrap(stdout)).toMatchSnapshot();
expect(wrap(summary)).toMatchSnapshot();
expect(wrap(rest)).toMatchInlineSnapshot(`
PASS __tests__/console.test.js
SimenB marked this conversation as resolved.
Show resolved Hide resolved
FAIL __tests__/console.test.js
● Test suite failed to run

TypeError: message.split is not a function

at buffer.reduce (../../packages/jest-util/build/getConsoleOutput.js:54:8)
at Array.reduce (<anonymous>)
`);
expect(status).toBe(0);
});
22 changes: 22 additions & 0 deletions e2e/console-winston/__tests__/console.test.js
@@ -0,0 +1,22 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';

const winston = require('winston');
const logger = winston.createLogger({
transports: [new winston.transports.Console()],
});

test('using winston should not fail', () => {
logger.log('info', 'Log message from winston');

logger.info('Info message from winston');

logger.warn('Warn message from winston');

logger.error('Error message from winston');
});
9 changes: 9 additions & 0 deletions e2e/console-winston/package.json
@@ -0,0 +1,9 @@
{
"jest": {
"testEnvironment": "node",
"verbose": false
},
"dependencies": {
"winston": "^3.2.1"
}
}