Jest
- Quickest and Simplest Way of Mocking Module Dependencies With Jest • Rodolfo Gobbi 📖
- The Power of Mocking in Unit Tests • Matthew Wolfe 📖
Vitest
- Fast Unit Testing With Vitest • Anthony Fu & Jason Lengstorf explain the differences between Vitest and Jest, then demonstrate how to install and configure Vitest and use it to write unit tests (including snapshot tests) • Learn with Jason 📺
- ESM is async by default, while CommonJS is sync by default
- When you require a CJS module, you can’t be sure that it’s ready to use
- This makes it hard to use Jest (which uses CJS) with Vite (which uses ESM)
- ESM is async by default, while CommonJS is sync by default
Mocking API responses
- 📺 Don’t Mock Fetch (or Axios): Use Mock Service Worker and Test Like a User • How to use msw to intercept an HTTP request with a service worker • Leigh Halliday 📺
Playwright
See writing/testing (since it can be used in multiple languages).
Cypress
- 📺 Cypress for Create React App (with code coverage and TypeScript) • 8 minute video by Basarat Ali showing how to install and configure Cypress to work in a React and TS project
- 📺 Get started with End to End testing using Cypress and TypeScript • 5 minute video by Basarat Ali showing how to use the Cypress test runner in visual and headless mode
- 📺 Why Cypress has taken over E2E testing • 1 minute video by Basarat Ali showing three reasons
cypress
has changed e2e testing for the better - 📺 UNIT testing your React components VISUALLY • 8 minute video by Basarat Ali showing how
cypress-react-unit-test
offers a better experience than@testing-library/react
for unit testing visual components - 📺 Cypress 5.0 Test Retries (and why you should use them) 🌹 • 4 minute video by Basarat Ali showing how to reduce test flakiness by enabling Cypress’ retries setting
- 📺 Cypress - Real World App - Setup and Walkthrough • 5 minute video by Basarat Ali giving a tour of the example cypress-realworld-app project, which demonstrates real-world usage of Cypress testing methods, patterns, and workflows
- 📺 Cypress in a Nutshell • 41 minute introductory webcast by Amir Rustamzadeh
- 📺 Cypress Crash Course: Learn full end-2-end testing using Cypress • 117 minute video by codedamn
E2E tests vs unit tests
- “Unpopular opinion: you should write E2E/integration tests first, always. They should be directly related to business logic (user) requirements. Only when an E2E/integration test fails should you even think about writing unit tests. And be willing to delete those unit tests.” • David K Piano 💬
- Maybe Don’t Write That Test • Philosophical Hacker 📖
- New to front-end testing? Start from the top of the pyramid! • Stefano Magni 📖
Inbox
-
Mocking | Guide | Vitest - how to mock a function’s return value - Vitest docs
-
jest/vitest: javascript - Difference between resetAllMocks, resetModules, resetModuleRegistry, restoreAllMocks in Jest - Stack Overflow - Stack Overflow