Can Jest Suppress Console Output Except on Test Failure When Testing?

13 views Asked by At

I'm interested in testing the foo function with Jest. This function contains a console.log statement within it. Is it feasible to configure Jest so that it only displays the console.log output when a test fails?

function foo() {
  ...
  console.log(...);
  ...
}

describe('....', () => {
  test(`...`, () => {
    const results = foo();
    expect(.........); 
  });
0

There are 0 answers