From 5a238f95660926478a441366b3d3a30521fc13f3 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Mon, 14 Aug 2023 08:49:35 -0400 Subject: [PATCH] test: Reduce test output noise (#53606) The errors, warnings, and logs from these tests are expected for each test case. However, their presence creates noise the reduce the comprehensibility of the test output. Intentionally suppressing them simplifies the test output, making it easier to identify new, unexpected console output. --- .../block-list/test/block-invalid-warning.native.js | 7 +++++++ packages/block-library/src/embed/test/index.native.js | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/packages/block-editor/src/components/block-list/test/block-invalid-warning.native.js b/packages/block-editor/src/components/block-list/test/block-invalid-warning.native.js index f75a63723b0a6..4cf4c0aec2ff0 100644 --- a/packages/block-editor/src/components/block-list/test/block-invalid-warning.native.js +++ b/packages/block-editor/src/components/block-list/test/block-invalid-warning.native.js @@ -11,6 +11,13 @@ import { setupCoreBlocks(); +beforeEach( () => { + // Intentionally suppress the expected console errors and warnings to reduce + // noise in the test output. + jest.spyOn( console, 'error' ).mockImplementation( () => {} ); + jest.spyOn( console, 'warn' ).mockImplementation( () => {} ); +} ); + describe( 'Block invalid warning', () => { it( 'shows invalid placeholder', async () => { // Arrange diff --git a/packages/block-library/src/embed/test/index.native.js b/packages/block-library/src/embed/test/index.native.js index 0fade6f51a9ed..c2e65bcef35c4 100644 --- a/packages/block-library/src/embed/test/index.native.js +++ b/packages/block-library/src/embed/test/index.native.js @@ -200,6 +200,10 @@ beforeEach( () => { MOCK_EMBED_PHOTO_SUCCESS_RESPONSE, MOCK_BAD_EMBED_PROVIDER_RESPONSE, ] ); + + // Intentionally suppress the expected console logs to reduce noise in the + // test output. + jest.spyOn( console, 'log' ).mockImplementation( () => {} ); } ); afterAll( () => {