jsdom

Some testing tools, such as Enzyme (we will learn about this in the following section), expect to be used in a web browser. In our example, the application uses nyc and ts-node to execute all our unit tests, which means that we are not using a web browser. Sometimes, it is possible to overcome this problem by using jsdom, which is described by its creators as follows:

"jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG DOM and HTML Standards, for use with Node.js. In general, the goal of the project is to emulate enough of a subset of a web browser to be useful for testing and scraping real-world web applications."

If we examine the nyc command in the package.json file included in the companion source ...

Get Learning TypeScript 2.x - Second Edition 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.