Creating test assertions, specs, and suites with Mocha and Chai
Now that the test infrastructure is ready, we will start writing a unit test. We need to remember that we are going to follow the BDD development testing style, which means that we will write the test before we actually write the code.
We will write a web calculator; because we want to keep it simple, we will only implement one of its features. After doing some analysis, we have come up with a design interface that will help us to understand the requirements. We will declare the following interface in the interfaces.d.ts
file:
interface MathInterface { PI : number; pow( base: number, exponent: number); }
As we can see, the calculator will allow us to calculate the exponent of a number ...
Get TypeScript: Modern JavaScript Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.