Here is an example of a mutation report showing that a mutation eliminating an HTML attribute that survived:
This is showing that the code:
Was mutated to the following (removing float: "right"
), without any tests failing (i.e. “the mutant survived”).
To fix this, you can add this to your test, where thisButton
is a handle to the button in question:
For example, here’s what that looks like in context.
With screen
included in the import from @testing-library/react
:
import { fireEvent, render, waitFor, screen } from "@testing-library/react";
We can write: