[[Jest]]で[[Parameterized Test]]を実施する方法。[[Jest Each]]を利用する。
```
import { excludeSpace } from "./strings";
describe("utils/strings", () => {
describe.each`
text | expected
${"aa bb"} | ${"aabb"}
${" pre"} | ${"pre"}
${"suf "} | ${"suf"}
${" both "} | ${"both"}
${" a ll "} | ${"all"}
`("excludeSpace", ({ text, expected }) => {
test(`excludeSpace(${text}) = ${expected}`, () => {
expect(excludeSpace(text)).toBe(expected);
});
});
});
```
## MOC
- 📒**関連**
- [[JestのParameterized Testを並列で実行]]
- [[describe.each]]
- [[test.concurrent.each]]
- 📜**アクティビティ**
- 📝**トラブルシューティング**
- [[📝Jestでdescribe.eachを使ったParameterized Testの型が推論されない]]