...

/

Solution Review: Writing a Parameterized Test

Solution Review: Writing a Parameterized Test

Learn to write a parameterized test for a function.

We'll cover the following...

Solution

function squared(input: number): number {
    return input * input;
}

describe('this is our test suite', () => {
    [1, 5, 10, 100].forEach(num =>
        it(`should multiply ${num}`, () => {
            const result = squared(num);

            expect(result).toEqual(num * num);
        }));
});
Test using describe function

Explanation

...