The companion source code includes a class named MathDemo. This class allows us to perform the pow calculation in a few different ways. One of them is the synchronous pow function:
public pow(base: number, exponent: number) { let result = base; for (let i = 1; i < exponent; i++) { result = result * base; } return result; }
As we learned in Chapter 9, Automating Your Development Workflow, we can test the method declared in the preceding function using the following test case:
it("Should return the correct numeric value for pow", () => { const math = new MathDemo(); const result = math.pow(2, 3); const expected = 8; expect(result).to.be.a("number"); expect(result).to.equal(expected); });
We can then use the nyc command with ...