I would like to write a set of tests in jest for the same function:
Lets say I have a function which adds numbers together
function add(a, b) {
return a + b;
}
Now I would like to write a set of tests which check a set of inputs to this function e.g.
| Test Name | Inputs | Expected Output |
|---|---|---|
| Positive Numbers | {a:1,b:5} |
6 |
| First Negative | {a: -1, b:5} |
4 |
| Second Negative | {a:1, b:-5} |
-4 |
| Both Negative | {a: -1, b:-5} |
-6 |
Also I would ideally have multiple cases for each test e.g. for Positive Numbers
{{a:1, b:5, out: 6}, {a:4, b:7, out: 11}, {a:2, b:20, out:22}}
How could I go about doing this?