🗂
jestで同じテストケースを複数の値で実行したいとき
jest で同じテストケースを複数の値で実行したいとき
How to
jest.each を使う
describe.each(table)(name, fn, timeout)
test.each(table)(name, fn, timeout)
describe.each([
[1, 1, 2],
[1, 2, 3],
[2, 1, 3],
])(".add(%i, %i)", (a, b, expected) => {
test(`returns ${expected}`, () => {
expect(a + b).toBe(expected);
});
test(`returned value not be greater than ${expected}`, () => {
expect(a + b).not.toBeGreaterThan(expected);
});
test(`returned value not be less than ${expected}`, () => {
expect(a + b).not.toBeLessThan(expected);
});
});
Discussion