Utilizing TypeScript and Jest, consider this sample test which can be found at https://jestjs.io/docs/api#testeachtablename-fn-timeout
it.each([
{ numbers: [1, 2, 3] },
{ numbers: [4, 5, 6] }
])('Test case %#: Amount is $numbers.length => $numbers', ({ numbers }) => {
expect(true).toBeTruthy();
});
The output of the test runner includes
✓ Test case 0: Amount is $numbers.length => $numbers (4ms)
Is there a way to substitute $numbers
with its actual value for further manipulation? For example, applying array functions on it.
An effective alternative approach could be
[
[1, 2, 3],
[4, 5, 6]
].forEach((numbers, index) => {
it(`Test case ${index}: Amount is ${numbers.length} => ${numbers}`, () => {
expect(true).toBeTruthy();
})
});
However, it's uncertain if this method is recommended by jest documentation.