Skip to content
how to use Jest to test pure JS + HTML page.
JavaScript HTML CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__
coverage
scripts
stylesheets
.gitignore
README.md
index.html
language.json
package-lock.json
package.json
setupJest.js

README.md

Testing example with plain HTML and JS

A simple example of how to use Jest to test pure JS + HTML page. With testing using jest-fetch-mock to test fetch calls.

How to use

Just clone this repo! Then use npm install to install all needed packages.

Start tests

All tests are located in __tests__ folder and you can change Jest's global variable setting in setupJest.js Run npm test to go through all tests. Default is set as jest --watch, you can change this behaviour in package.json.

Know your coverage

All coverage report located in coverage folder and reports are generated by Jest. Run npm run coverage to get the latest coverage report.

Demo

Demo of HTML: View here

You can’t perform that action at this time.