Skip to content

Adding Test Coverage

Ben Blazke edited this page Dec 2, 2020 · 33 revisions

Preparation

Clone the git repo https://github.com/coursehero/ch-react-workshop and follow the instructions in README.

The recommended IDE is Visual Studio Code but you can use any IDE or editor you like.

In your terminal window start the Python server with ./server.sh. Open another terminal and start the React development server with ./client.sh. This will also install any necessary local prerequisites.

If everything is set up correctly, a browser window should open up with a Document Landing page (http://localhost:3000/APP).

Installing dependencies

Let's install Cypress, Cypress Testing Library and aXe.

Tip: We recommend installing specific versions to make sure CI doesn't break when package maintainers release new and incompatible versions.

cd js/doc-landing

npm install -D cypress@6.0.1 @testing-library/cypress@7.0.2 cypress-axe@0.12.0

npx cypress open

The Cypress Electron app should open up with the official list of examples. Feel free to run and study them on your own.

Next, open cypress/support/commands.js and add the following line:

import '@testing-library/cypress/add-commands';

Finally, open js/doc-landing/tsconfig.json and add this line to compilerOptions:

"types": ["cypress", "@testing-library/cypress"]

Now you're ready to write some tests!

Next steps

Clone this wiki locally