Testing learning materials
Free courses
- Net Ninja - React Testing Library tutorial series
- Traversy Media - React Testing Crash Course
- Jack Herrington - Testing with Jest and Wallaby
- Jack Herrington - TypeScript/React Testing: Components, Hooks, Custom Hooks, Redux and Zustand
Polish free courses
- Frontlive - Testowanie JS - podstawy
- Frontlive - Jest - pierwszy test
- Frontlive - Jest - mock functions
- Frontlive - React Testing Library - podstawy
- Frontlive - React Testing Library - testy w praktyce
- Frontlive - React Testing Library - Mock Service Worker
Paid courses
Additional content
Jest
Vitest: an alternative to Jest
Why choose Vitest?
- built in typescript support
- chai and jest compatible assertions
- works out of the box with super fast build tool: Vite
Vitest materials
-
thisdot.co - Testing with Vitest by Ignacio Falk
Protip: You can use Vitest like Jest, just some minor adjustments are needed for it to work. You can watch Jest tutorials to learn Vitest
Import modules for testing as globals in config
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
plugins: [svelte({ hot: !process.env.VITEST })],
test: {
globals: true,
environment: 'jsdom',
},
});
End to end testing
Testing principles
- Kent C. Dodds - The Testing Trophy and Testing Classifications
- Kent C. Dodds - Static vs Unit vs Integration vs E2E Testing for Frontend Apps
- Fireship - Test-Driven Development // Fun TDD Introduction with JavaScript
- Jack Herrington - Test Driven Development: The best way to code that I almost never use
- Kent C. Dodds - AHA Testing (how to test wisely)
Structure of a test
- Arrange - set up the test data, test conditions, and test environment
- Act - run logic that should be tested (eg. execute function), click a button
- Assert - compare the expected result with the actual result
Types of tests
- Unit tests - testing an isolated function
- Integration tests - testing a component that uses other components, testing things working together
- End to end tests - testing user interaction with UI