✅ How to test a web application with functional browser tests (aka E2E tests)
Check if you have an app running on http://localhost:3000/
. If so, you are ready.
If not, then
Open a terminal
cd web-testing-2022/
npm start
Open application at http://localhost:3000/
- ❓What is the most basic test that we can code for our application?
- ❓What other tests can we code?
"Fast, easy and reliable testing for anything that runs in a browser."(Cypress.io)
In new terminal, without stopping the web app
npx cypress open
💡 Tests live in cypress/e2e
folder
- In your IDE open
cypress/e2e/exercise.cy.js
- Follow instructions to implement
it('loads')
test
- In your IDE open
cypress/e2e/exercise.spec.js
- Follow instructions to implement
it('link goes to ultimateqa')
test
- Follow instructions in this test
it('should open link in new tab')
Click here to see answer.
- Need a browser
- Need a server
- Need to deal with network issues
- Test will be slower
- Need an extra dependency (Cypress)
- Need to learn extra dependency API
Click here to see answer.
Using component tests
-
Cypress 10 component testing workshop by Gleb Bahmutov on Oct 19th 10AM EST.
-
How to run a component test w/ Jest followed by
✅ E2E UI testing with Cypress allows us to do functional testing of the web app
✅ We can test a link by checking the href
attribute
✅ We can test that a url opens a new tab with target='_blank'