[jest/ci] disable console methods (#146910)

Removes all the noise from poorly written React tests and includes a
warning to explain the situation to folks

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Spencer 2022-12-02 16:28:55 -06:00 committed by GitHub
parent 877d775a76
commit c107f8a73a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View file

@ -26,6 +26,13 @@ echo "--- downloading jest test run order"
download_artifact jest_run_order.json .
configs=$(jq -r 'getpath([env.TEST_TYPE]) | .groups[env.JOB | tonumber].names | .[]' jest_run_order.json)
echo "+++ ⚠️ WARNING ⚠️"
echo "
console.log(), console.warn(), and console.error() output in jest tests causes a massive amount
of noise on CI without any percevable benefit, so they have been disabled. If you want to log
output in your test temporarily, you can modify 'packages/kbn-test/src/jest/setup/disable_console_logs.js'
"
while read -r config; do
echo "--- $ node scripts/jest --config $config"

View file

@ -91,7 +91,10 @@ module.exports = {
'<rootDir>/node_modules/@kbn/test/target_node/src/jest/setup/mocks.moment_timezone.js',
'<rootDir>/node_modules/@kbn/test/target_node/src/jest/setup/mocks.eui.js',
'<rootDir>/node_modules/@kbn/test/target_node/src/jest/setup/react_testing_library.js',
],
process.env.CI
? '<rootDir>/node_modules/@kbn/test/target_node/src/jest/setup/disable_console_logs.js'
: [],
].flat(),
snapshotFormat: {
escapeString: true,

View file

@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
// on CI these logs just muddy up the console and produce a ton of unnecessary noise
console.log = () => {};
console.error = () => {};
console.warn = () => {};