HTML-based tests
Jest uses a library named jsdom to allow for testing HTML elements and interactions. Jsdom is not an actual browser; it is a library that implements the JavaScript DOM API, and can, therefore, simulate a full-blown browser experience. The benefit of using jsdom is in the speed at which we can run our tests, and the fact that we do not have to provide an environment that can run a full browser. Running a full internet browser generally assumes that the tests are running on a standard computer, and as such, has an actual screen. This means that virtual machines that run tests must be configured with a screen, and adds the extra requirements of having a screen driver that can run at the required resolution.
We can install the jsdom library using npm as follows:
npm install jsdom --save-dev
While we are at it, let's install the jquery library as well:
npm install jquery
And the @types
declaration files for both libraries as follows:
npm...