profile

Hello, I'm Wojciech đź‘‹

Mocking in E2E is fine


The term end-to-end tests is misleading, because the same way the horizon changes when you change you point of view, the “ends” also change when you have a different perspective. I once wrote:

Let’s take a look at an imaginary ecommerce app. For a developer from a checkout team E2E test would probably mean: user picks some items, proceeds to checkout, fills in all their details, pays, order is created. But for an actual user, the “end-to-end” means: they were able to find a product that they were looking for (even though they misspelled the name of the brand), they could clearly see the differences between various models, they could order abroad, download an invoice with correct VAT tax amount and finally, they got the item in the mail.

It’s not important if your tests are written “the right way”. It’s important if they’re useful and give you confidence.

So, mocking things (especially network and other systems) in your E2E is completely fine.
​

Have a good one,

Wojciech

​

PS. I have lovingly crafted this email using only the best artisanal keystrokes. If you find come across any typos, feel free to fix them yourself and enjoy this new, unique, kintsugi version.

Hello, I'm Wojciech đź‘‹

Subscribe to read my programming experiences, ideas, mistakes and tips I wish I'd known myself earlier. Learn how to enable high-performing teams, make an impact, grow as a software engineer and level up your career.

Share this page