Mastering Mocking in Playwright: Simplify API Test Automation
summary
Live demo shows Playwright’s built-in mocking replacing external tools like WireMock or Mockito and working end-to-end: tests redirects requests to a different endpoint so calling demo.playwright.dev/api/mocking returns only “strawberry” instead of the full fruit list, tests modifies JSON responses at runtime to inject a new item, and examples add a synthetic item with id:100; covers stubs vs spies, three concrete patterns, and runnable code that executes successfully.
AI-written summary · about
chapters (8)
- 0:00Introduction to mocking
- 1:11What is API testing
- 3:40Why mocking is needed
- 5:02Stub vs spy explained
- 5:45Playwright mocking benefits
- 6:47Mock API request demo
- 10:41Modify API response demo
- 14:11Additional resources
related talks
51mAdvanced Playwright Techniques for Flawless Testing
25mFakes over Mocks: Shift your paradigm and identify monolithic code
49mFor those about to Mock I salute you!
30mBreak the API Test Data Bottleneck: Real Scenarios on Real Systems
41mTesting Web Applications with Playwright
40mStrategic Business Functionality Testing: Accelerating Development Through Mocking
32mPlaywright Component Tests: Are they the Testing-Library killer?
24mMocking made easy
