3 ms·
> Sometimes I want to directly control a browser to run a test or examine a UI component, but I still want to mock parts of my application. If you're building
by Qerub 7y ago
> Sometimes I want to directly control a browser to run a test or examine a UI component, but I still want to mock parts of my application.
If you're building a SPA, you can mock out the backend and control the backend mock behaviour in your Selenium test.
- danShumway 7y agoIt's not that Selenium makes it impossible to do things like this, it's that it makes it arbitrarily harder. If you want to do something like request interception, you have to point your front-end at a proxy server and mock things there. If you want to test a file upload, you have to simulate typing into the dialog and then use a literal file on the disk. It's just pointless friction for most testing setups. It's not that E2E testing is bad, it's that in some projects there's room for a Selenium-style tool across the entire spectrum from E2E testing to unit testing; particularly if I'm testing something like D3 code, or parts of a CSS layout. It's all doable, it's just that Selenium makes it all needlessly difficult, because its point-of-view is that your front-end should be treated mostly like a black box, and that any mocking that does exist should be happening via endpoints and application connectors. I like Selenium -- I prefer using an Open protocol over Puppeteer. I just feel like that protocol could use a lot more design work.