Closed cagross closed 4 years ago
Indeed, you’d make an array of test cases, iterate that array, and assert on each item.
For tape to try to support this natively would either require adding complexity to every assertion type, or, providing a single utility that was just a shallow wrapper around array map, which is already in the language.
Once utility that’s useful when doing tests on a large array is collapsing all the assertions into one TAP output line.
https://github.com/raynos/collapsed-assert
I use this small library with loops quite often to avoid seeing one thousand TAP output lines on a test.
TIL, that's really nice.
Sorry for the late reply, but thanks to both. I'll start with a simple array as @ljharb suggested, and consider the collapse utility suggested by @Raynos. We can consider this resolved.
Hello. I've written my first test using Tape--in my test I call one of my functions, pass to it a sample 'test' object, and assert the return value is a number. The test passes as expected. I'd now like to create several more 'test' objects, and ensure my Tape test is executed over and over, once for each object. Is there a built-in way to do this in Tape, e.g. a special 'batch' test or something? Or would I be responsible for writing the code to do that (e.g. saving all 'test' objects to a single array, then loop over the array and carry out my test on each array element)?
Thanks.