Skip to content

Instantly share code, notes, and snippets.

@hisasann
Created April 13, 2020 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisasann/964f98064b86d15eac04c9c731dddff5 to your computer and use it in GitHub Desktop.
Save hisasann/964f98064b86d15eac04c9c731dddff5 to your computer and use it in GitHub Desktop.
describe.each でデータ行ごとに回す処理をテンプレートリテラルで書く方法
// 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