Link Search Menu Expand Document

Local Conventions

To run jest on repos set up using the Spring/React conventions used in CS156, use these commands:

Note: All of these are run from the javascript subdirectory of the project.

Command Description
npm test runs the test suite
npm run coverage generates a coverage report

The detailed coverage report (with line-by-line reports for each source file) can be found by opening this file in a web browser:

  • javascript/coverage/lcov-report/index.html

Hiding the “Wall Of Red”

When testing with Jest, especially when mocking 404 errors, you can get a wall of red error messages, even on a passing test, like this:

image

To avoid it, you can temporarily redirect the output of console.error. Note that this can hide error messages that you might sometimes need to see, so use this sparingly.