Fix the hollow test finder for an Enzyme migration

Review the AI's codeEasy10 min

Your task

An AI agent moved your React tests from Enzyme to Testing Library. Every migrated test passes and coverage held steady, but a test can pass without checking anything. To find out, you break the component on purpose in several ways (each broken build is a mutant) and record which tests fail.

An assistant wrote find_hollow_tests(test_names, mutant_results). It is in the editor. It has a bug. Find it and fix it.

Input and output:

  • test_names: the migrated tests, in order. Names may repeat, and each position is its own test.
  • mutant_results: one row per mutant, one entry per test in the same order as test_names.
  • Return the names of the hollow tests.

Rules the tests check:

  • An entry other than 0 means that test failed against that mutant. Runners report different values here, not only 1.
  • A test is hollow when it failed against no mutant. With no rows at all, every test is hollow.
  • A row shorter than test_names counts as 0 for the missing tests. Entries past the end of test_names are ignored.
  • Return the hollow names in input order.

Examples

find_hollow_tests(test_names: list[str], mutant_results: list[list[int]]) -> list[str]
Example 1
Inputfind_hollow_tests(["renders title", "calls onSave", "shows error"], [[1, 0, 0], [0, 1, 0], [1, 1, 0]])
Output["shows error"]
Example 2
Inputfind_hollow_tests(["a", "b"], [])
Output["a", "b"]
Example 3
Inputfind_hollow_tests([], [[1, 1]])
Output[]