Define unit test case to run it multiple times
For that use case, I have created simple jasmine utility function, that will iterate through array of input data and create the same test case for each input data. What is more it will pass current input data to the particular test case, so you can use it to actually test the code. The helper function is defined in seperate file - jasmine-utils.ts.
The following example shows, how to use testCases function to run the same test case multiple times. It’s very easy, clean and intuitive.
You can see the result of running the code above using karma and mocha reporter. As you can notice, each test case is run separately and report the input data that was provided to test particular scenario.
I hope you like my helper and in every day work always remember to unit test your code :) If you have any questions or insights, please leave me a comment below.