From 53b6c07b7543311757eac0938b34d367d8a10957 Mon Sep 17 00:00:00 2001 From: Alcedo Nathaniel De Guzman Jr Date: Sat, 2 Mar 2019 18:44:43 +0800 Subject: [PATCH 1/4] Add an end to end test for using winston for loggin --- .../__snapshots__/console.test.ts.snap | 10 +++++++++ e2e/__tests__/console.test.ts | 19 ++++++++++++++++ e2e/console-winston/__tests__/console.test.js | 22 +++++++++++++++++++ e2e/console-winston/package.json | 9 ++++++++ 4 files changed, 60 insertions(+) create mode 100644 e2e/console-winston/__tests__/console.test.js create mode 100644 e2e/console-winston/package.json diff --git a/e2e/__tests__/__snapshots__/console.test.ts.snap b/e2e/__tests__/__snapshots__/console.test.ts.snap index e67f28aa3c2f..4dd2642707a6 100644 --- a/e2e/__tests__/__snapshots__/console.test.ts.snap +++ b/e2e/__tests__/__snapshots__/console.test.ts.snap @@ -50,6 +50,16 @@ Time: <> 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: <> +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`; diff --git a/e2e/__tests__/console.test.ts b/e2e/__tests__/console.test.ts index b0aaeab78322..c81d0ee4d2a9 100644 --- a/e2e/__tests__/console.test.ts +++ b/e2e/__tests__/console.test.ts @@ -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 +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 () +`); + expect(status).toBe(0); +}); diff --git a/e2e/console-winston/__tests__/console.test.js b/e2e/console-winston/__tests__/console.test.js new file mode 100644 index 000000000000..c85c9ef25ef3 --- /dev/null +++ b/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'); +}); diff --git a/e2e/console-winston/package.json b/e2e/console-winston/package.json new file mode 100644 index 000000000000..2664d92fa106 --- /dev/null +++ b/e2e/console-winston/package.json @@ -0,0 +1,9 @@ +{ + "jest": { + "testEnvironment": "node", + "verbose": false + }, + "dependencies": { + "winston": "^3.2.1" + } +} From 3d583949403f71d8ff1acbb874263bc46ddc4541 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 2 Mar 2019 12:45:12 +0100 Subject: [PATCH 2/4] fix test --- .../__snapshots__/console.test.ts.snap | 19 +- e2e/__tests__/console.test.ts | 20 +- e2e/console-winston/yarn.lock | 246 ++++++++++++++++++ packages/jest-util/package.json | 2 - packages/jest-util/src/BufferedConsole.ts | 14 +- 5 files changed, 278 insertions(+), 23 deletions(-) create mode 100644 e2e/console-winston/yarn.lock diff --git a/e2e/__tests__/__snapshots__/console.test.ts.snap b/e2e/__tests__/__snapshots__/console.test.ts.snap index 4dd2642707a6..8077db761de9 100644 --- a/e2e/__tests__/__snapshots__/console.test.ts.snap +++ b/e2e/__tests__/__snapshots__/console.test.ts.snap @@ -53,7 +53,24 @@ 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 +PASS __tests__/console.test.js + ● Console + + console.log node_modules/winston/lib/winston/transports/console.js:79 + {"level":"info","message":"Log message from winston"} + + console.log node_modules/winston/lib/winston/transports/console.js:79 + {"message":"Info message from winston","level":"info"} + + console.log node_modules/winston/lib/winston/transports/console.js:79 + {"message":"Warn message from winston","level":"warn"} + + console.log node_modules/winston/lib/winston/transports/console.js:79 + {"message":"Error message from winston","level":"error"} +`; + +exports[`does not error out when using winston 3`] = ` +Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: <> diff --git a/e2e/__tests__/console.test.ts b/e2e/__tests__/console.test.ts index c81d0ee4d2a9..f547a9daeb36 100644 --- a/e2e/__tests__/console.test.ts +++ b/e2e/__tests__/console.test.ts @@ -5,8 +5,9 @@ * LICENSE file in the root directory of this source tree. */ +import path from 'path'; import {wrap} from 'jest-snapshot-serializer-raw'; -import {extractSummary} from '../Utils'; +import {extractSummary, run} from '../Utils'; import runJest from '../runJest'; test('console printing', () => { @@ -61,20 +62,13 @@ test('the jsdom console is the same as the test console', () => { }); test('does not error out when using winston', () => { - const {stderr, stdout, status} = runJest('console-winston'); + const dir = path.resolve(__dirname, '../console-winston'); + run('yarn', dir); + const {stderr, stdout, status} = runJest(dir); const {summary, rest} = extractSummary(stderr); + expect(status).toBe(0); expect(wrap(stdout)).toMatchSnapshot(); + expect(wrap(rest)).toMatchSnapshot(); expect(wrap(summary)).toMatchSnapshot(); - expect(wrap(rest)).toMatchInlineSnapshot(` -PASS __tests__/console.test.js -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 () -`); - expect(status).toBe(0); }); diff --git a/e2e/console-winston/yarn.lock b/e2e/console-winston/yarn.lock new file mode 100644 index 000000000000..bc3f66b2a50c --- /dev/null +++ b/e2e/console-winston/yarn.lock @@ -0,0 +1,246 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +async@^2.6.1: + version "2.6.2" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.2.tgz#18330ea7e6e313887f5d2f2a904bac6fe4dd5381" + integrity sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg== + dependencies: + lodash "^4.17.11" + +color-convert@^1.9.1: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + +color-name@^1.0.0: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +color-string@^1.5.2: + version "1.5.3" + resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.5.3.tgz#c9bbc5f01b58b5492f3d6857459cb6590ce204cc" + integrity sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw== + dependencies: + color-name "^1.0.0" + simple-swizzle "^0.2.2" + +color@3.0.x: + version "3.0.0" + resolved "https://registry.yarnpkg.com/color/-/color-3.0.0.tgz#d920b4328d534a3ac8295d68f7bd4ba6c427be9a" + integrity sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w== + dependencies: + color-convert "^1.9.1" + color-string "^1.5.2" + +colornames@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/colornames/-/colornames-1.1.1.tgz#f8889030685c7c4ff9e2a559f5077eb76a816f96" + integrity sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y= + +colors@^1.2.1: + version "1.3.3" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.3.tgz#39e005d546afe01e01f9c4ca8fa50f686a01205d" + integrity sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg== + +colorspace@1.1.x: + version "1.1.1" + resolved "https://registry.yarnpkg.com/colorspace/-/colorspace-1.1.1.tgz#9ac2491e1bc6f8fb690e2176814f8d091636d972" + integrity sha512-pI3btWyiuz7Ken0BWh9Elzsmv2bM9AhA7psXib4anUXy/orfZ/E0MbQwhSOG/9L8hLlalqrU0UhOuqxW1YjmVw== + dependencies: + color "3.0.x" + text-hex "1.0.x" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= + +diagnostics@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/diagnostics/-/diagnostics-1.1.1.tgz#cab6ac33df70c9d9a727490ae43ac995a769b22a" + integrity sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ== + dependencies: + colorspace "1.1.x" + enabled "1.0.x" + kuler "1.0.x" + +enabled@1.0.x: + version "1.0.2" + resolved "https://registry.yarnpkg.com/enabled/-/enabled-1.0.2.tgz#965f6513d2c2d1c5f4652b64a2e3396467fc2f93" + integrity sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M= + dependencies: + env-variable "0.0.x" + +env-variable@0.0.x: + version "0.0.5" + resolved "https://registry.yarnpkg.com/env-variable/-/env-variable-0.0.5.tgz#913dd830bef11e96a039c038d4130604eba37f88" + integrity sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA== + +fast-safe-stringify@^2.0.4: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz#04b26106cc56681f51a044cfc0d76cf0008ac2c2" + integrity sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg== + +fecha@^2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fecha/-/fecha-2.3.3.tgz#948e74157df1a32fd1b12c3a3c3cdcb6ec9d96cd" + integrity sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg== + +inherits@^2.0.3, inherits@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= + +is-arrayish@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" + integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== + +is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= + +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + +kuler@1.0.x: + version "1.0.1" + resolved "https://registry.yarnpkg.com/kuler/-/kuler-1.0.1.tgz#ef7c784f36c9fb6e16dd3150d152677b2b0228a6" + integrity sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ== + dependencies: + colornames "^1.1.1" + +lodash@^4.17.11: + version "4.17.11" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" + integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== + +logform@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/logform/-/logform-2.1.2.tgz#957155ebeb67a13164069825ce67ddb5bb2dd360" + integrity sha512-+lZh4OpERDBLqjiwDLpAWNQu6KMjnlXH2ByZwCuSqVPJletw0kTWJf5CgSNAUKn1KUkv3m2cUz/LK8zyEy7wzQ== + dependencies: + colors "^1.2.1" + fast-safe-stringify "^2.0.4" + fecha "^2.3.3" + ms "^2.1.1" + triple-beam "^1.3.0" + +ms@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== + +one-time@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/one-time/-/one-time-0.0.4.tgz#f8cdf77884826fe4dff93e3a9cc37b1e4480742e" + integrity sha1-+M33eISCb+Tf+T46nMN7HkSAdC4= + +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + integrity sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw== + +readable-stream@^2.3.6: + version "2.3.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" + integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +readable-stream@^3.1.1: + version "3.2.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.2.0.tgz#de17f229864c120a9f56945756e4f32c4045245d" + integrity sha512-RV20kLjdmpZuTF1INEb9IA3L68Nmi+Ri7ppZqo78wj//Pn62fCoJyV9zalccNzDD/OuJpMG4f+pfMl8+L6QdGw== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +simple-swizzle@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" + integrity sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo= + dependencies: + is-arrayish "^0.3.1" + +stack-trace@0.0.x: + version "0.0.10" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" + integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= + +string_decoder@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.2.0.tgz#fe86e738b19544afe70469243b2a1ee9240eae8d" + integrity sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w== + dependencies: + safe-buffer "~5.1.0" + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + +text-hex@1.0.x: + version "1.0.0" + resolved "https://registry.yarnpkg.com/text-hex/-/text-hex-1.0.0.tgz#69dc9c1b17446ee79a92bf5b884bb4b9127506f5" + integrity sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg== + +triple-beam@^1.2.0, triple-beam@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" + integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw== + +util-deprecate@^1.0.1, util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= + +winston-transport@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.3.0.tgz#df68c0c202482c448d9b47313c07304c2d7c2c66" + integrity sha512-B2wPuwUi3vhzn/51Uukcao4dIduEiPOcOt9HJ3QeaXgkJ5Z7UwpBzxS4ZGNHtrxrUvTwemsQiSys0ihOf8Mp1A== + dependencies: + readable-stream "^2.3.6" + triple-beam "^1.2.0" + +winston@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/winston/-/winston-3.2.1.tgz#63061377976c73584028be2490a1846055f77f07" + integrity sha512-zU6vgnS9dAWCEKg/QYigd6cgMVVNwyTzKs81XZtTFuRwJOcDdBg7AU0mXVyNbs7O5RH2zdv+BdNZUlx7mXPuOw== + dependencies: + async "^2.6.1" + diagnostics "^1.1.1" + is-stream "^1.1.0" + logform "^2.1.1" + one-time "0.0.4" + readable-stream "^3.1.1" + stack-trace "0.0.x" + triple-beam "^1.3.0" + winston-transport "^4.3.0" diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index 4fceefa7a5da..5808a8f03640 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -18,7 +18,6 @@ "graceful-fs": "^4.1.15", "is-ci": "^2.0.0", "mkdirp": "^0.5.1", - "readable-stream": "^3.1.1", "slash": "^2.0.0", "source-map": "^0.6.0" }, @@ -26,7 +25,6 @@ "@types/graceful-fs": "^4.1.2", "@types/is-ci": "^1.0.10", "@types/mkdirp": "^0.5.2", - "@types/readable-stream": "^2.3.0", "@types/slash": "^2.0.0" }, "engines": { diff --git a/packages/jest-util/src/BufferedConsole.ts b/packages/jest-util/src/BufferedConsole.ts index 8312b314444f..04f7f01b6e4a 100644 --- a/packages/jest-util/src/BufferedConsole.ts +++ b/packages/jest-util/src/BufferedConsole.ts @@ -8,7 +8,6 @@ import assert from 'assert'; import {Console} from 'console'; import {format} from 'util'; -import {Writable} from 'readable-stream'; import chalk from 'chalk'; import {Console as ConsoleType, SourceMaps} from '@jest/types'; import getCallsite from './getCallsite'; @@ -24,12 +23,13 @@ export default class BufferedConsole extends Console { getSourceMaps: () => SourceMaps.SourceMapRegistry | null | undefined, ) { const buffer: ConsoleType.ConsoleBuffer = []; - super( - new Writable({ - write: message => - BufferedConsole.write(buffer, 'log', message, null, getSourceMaps()), - }), - ); + super({ + write: (message: string) => { + BufferedConsole.write(buffer, 'log', message, null, getSourceMaps()); + + return true; + }, + } as NodeJS.WritableStream); this._getSourceMaps = getSourceMaps; this._buffer = buffer; this._counters = {}; From 1df9c22448efe50039e3ffb01a5977497e329fa7 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 2 Mar 2019 12:48:08 +0100 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49ae4c0ab879..10517c26bc96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ - `[jest-serializer]`: Migrate to TypeScript ([#7841](https://github.com/facebook/jest/pull/7841)) - `[jest-message-util]`: Migrate to TypeScript ([#7834](https://github.com/facebook/jest/pull/7834)) - `[@jest/types]`: New package to handle shared types ([#7834](https://github.com/facebook/jest/pull/7834)) -- `[jest-util]`: Migrate to TypeScript ([#7844](https://github.com/facebook/jest/pull/7844)) +- `[jest-util]`: Migrate to TypeScript ([#7844](https://github.com/facebook/jest/pull/7844), [#8021](https://github.com/facebook/jest/pull/8021)) - `[jest-watcher]`: Migrate to TypeScript ([#7843](https://github.com/facebook/jest/pull/7843)) - `[jest-mock]`: Migrate to TypeScript ([#7847](https://github.com/facebook/jest/pull/7847), [#7850](https://github.com/facebook/jest/pull/7850), [#7971](https://github.com/facebook/jest/pull/7971)) - `[jest-worker]`: Migrate to TypeScript ([#7853](https://github.com/facebook/jest/pull/7853)) From 3012e443415886686e35b04a5fe361ff53ce2307 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 2 Mar 2019 13:03:39 +0100 Subject: [PATCH 4/4] update snapshot --- e2e/__tests__/__snapshots__/consoleAfterTeardown.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/__tests__/__snapshots__/consoleAfterTeardown.test.ts.snap b/e2e/__tests__/__snapshots__/consoleAfterTeardown.test.ts.snap index 07ff6d62433e..6638d30b4faa 100644 --- a/e2e/__tests__/__snapshots__/consoleAfterTeardown.test.ts.snap +++ b/e2e/__tests__/__snapshots__/consoleAfterTeardown.test.ts.snap @@ -15,6 +15,6 @@ PASS __tests__/console.test.js 15 | }); 16 | - at BufferedConsole.log (../../packages/jest-util/build/BufferedConsole.js:182:10) + at BufferedConsole.log (../../packages/jest-util/build/BufferedConsole.js:172:10) at log (__tests__/console.test.js:13:13) `;