Skip to content

Commit

Permalink
FAQ about parameterized testing
Browse files Browse the repository at this point in the history
Fixes #170
  • Loading branch information
sgravrock committed Oct 26, 2024
1 parent f3ef4f9 commit 4862c9b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions _faq/testing/parameterized.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
question: Does Jasmine support parameterized testing?
---

Not directly. But test suites are just JavaScript, so you can do it anyway.

```javascript
function add(a, b) {
return a + b;
}

describe('add', function() {
const cases = [
{first: 3, second: 3, sum: 6},
{first: 10, second: 4, sum: 14},
{first: 7, second: 1, sum: 8}
];

for (const {first, second, sum} of cases) {
it(`returns ${sum} for ${first} and ${second}`, function () {
expect(add(first, second)).toEqual(sum);
});
}
});
```

0 comments on commit 4862c9b

Please sign in to comment.