Hacker News new | ask | show | jobs
by tootie 2928 days ago
This isn't selenium. More like wiremock.
1 comments

What's the core distinction between this/wiremock vs selenium?
Selenium is for behavior testing. Simulating clicks and form filling. This is for mocking http endpoints.
I still don't get why we do this [mocking http endpoints].

Sure this makes the problem of mocking the server less painful. Well done. But I'd take completely integrated tests over these any day. Sure they're slower but that's more or less irrelevant with feature toggling, staged roll-out and continuous production monitoring.

It's totally possible to completely avoid mocking http endpoints thus making these tools completely obsolete.

See my comment above. This is not a replacement for E2E testing.
It's not always easy. Especially not if your API is stateful.
Or if it's not your API. I've been looking for something like this to make mocking OAuth flow a lot easier.
The example is form filling though:

    await fillIn('email', 'polly@netflix.com');
    await fillIn('password', '@pollyjs');
This is exactly like selenium code I've written to login. I struggle to see the difference in purpose.
In your selenium code, the browser was talking to a database.

But sometimes that database is down, or really slow.

Polly says "browser, don't talk to the database anymore, instead here's what the database said last time".

So, yes, both Selenium and Polly poke DOM elements, but Selenium stops there, where as Polly does that + as well as tricks the browser into going through the whole test without making a real call to the database (assuming it has a previous recording of "what the database said" for that test).

That's part of mocha or whatever. Polly is the server part.
> /* start: pseudo test code */