Fill: test.each
Fill in the Blank Medium
Question
Fill in the blank to create a parameterized test:
Code
___.each([[1, 1, 2], [2, 3, 5]])(
'adds %i + %i = %i',
(a, b, expected) => {
expect(a + b).toBe(expected);
}
);
Hint
It's the same test function with an .each modifier.
Explanation
The correct answer is test. test.each(table) creates a parameterized test that runs once for each row in the table. Each row's values are passed as arguments to the test callback. This is a powerful way to test multiple scenarios with one test definition.
Related Resources
Related Lessons
- Parameterized Tests
Data-driven testing.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.