Skip to content

Fail Jest tests if warnings or errors are logged to the console

Sarah German requested to merge jest-fail-on-warn into main

What does this MR do and why?

Adds a package and configuration to Jest in order to have it return a Fail if tests encounter console errors or warnings.

Jest core doesn't do this (and people have lots of opinions about that).

We encountered a minor regression recently after upgrading a package that could've been caught pre-merge if the warnings in yarn test had caused a pipeline failure.

Screenshots, screen recordings, or links to review app

How to set up and validate locally

  1. Check out commit 06329d (a recent merge on main that had a jest test with errors) and run yarn test. You should see errors, but the tests pass.
  2. Check out the jest-fail-on-warn branch and run yarn test. You should see errors, and the test with errors fails.

Merge request acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sarah German

Merge request reports