Pattern: Manual test loop
Issue: -
Using manual loops for test cases is less readable and more error-prone than using Jest's built-in each
functionality, which provides a clearer way to handle parameterized tests.
Example of incorrect code:
for (const item of items) {
it("should process item", () => {
expect(process(item)).toBe("result");
});
}
Example of correct code:
it.each(items)("should process item", (item) => {
expect(process(item)).toBe("result");
});