Four approaches to testing a web page that fetches server data are compared, progressing from reading DOM values to spying on network calls, stubbing responses, and finally a 'verify then control' pattern. The recommended approach uses schema validation on real server responses before substituting mock data, ensuring tests remain deterministic without duplicating app logic or blindly trusting stubs that may drift from the actual API contract.

4m read timeFrom glebbahmutov.com
Post cover image
Table of contents
Compute the data in the testGet the data from the network callsStub the network callsVerify then control the dataSee also
3 Impressions