This is the companion code to the talk at https://robrich.org/slides/web-test-all-the-things/
In this talk we look at testing TypeScript Web Apps (PWA / SPA). We examine tests in these categories:
- hello testing typescript
- unit test a function
- without mocks
- mock dependencies
- mock parameters
- unit test a component
- assert rendering
- assert behaviors
- integration testing (from here down)
- external API validation
- end-to-end UI tests
- custom commands
- mock network requests
- smoke tests
We explore these NPM packages:
-
Start Redis in Docker by running
docker-compose up -
Start api by running this from a terminal:
cd api npm install npm startthen browse to http://localhost:3000/
-
Start the vue app by running this from a terminal:
cd app npm install npm run dev
-
Start Redis in Docker by running
docker-compose up -
Don't start the app or api, and kill them if they're running
-
From a terminal run this:
cd api npm run test cd .. cd app npm run test cd ..
See also the GitHub Actions build file in .github/workflows/build-and-test.yaml
Cypress is configured with cypress.config.ts (v10+). To run locally with the app auto-started:
-
Start Redis in Docker by running
docker compose up -
Start the api
cd api npm run start -
Cypress starts the app
cd app npm run cy:open
MIT