Created
April 13, 2020 01:34
-
-
Save hisasann/964f98064b86d15eac04c9c731dddff5 to your computer and use it in GitHub Desktop.
describe.each でデータ行ごとに回す処理をテンプレートリテラルで書く方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://jestjs.io/docs/en/api#describeeachtablename-fn-timeout | |
describe.each` | |
a | b | expected | |
${1} | ${1} | ${2} | |
${1} | ${2} | ${3} | |
${2} | ${1} | ${3} | |
`('$a + $b', ({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); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment