DEV Community

Discussion on: Cypress - End to End Testing Framework

Collapse
 
dmitry profile image
Dmitry Polushkin • Edited

In rails you normally can use FactoryBot through middleware on server side and commands to clean/setup specs in cypress. Doing calls to your real app makes everything updated, no need to write mocks, especially it can be a problem for websocket apps (not enough tools for now to mock websocket). So in other words you are doing integration testing, which is higher level, with easiness of unit testing - which is absolutely great and fast enough.

One of the solutions: github.com/shakacode/cypress-on-rails

Collapse
 
yucer profile image
yucer

I do also like to test the middle-ware directly.

It forces you to keep all the logic away from client code.

If someone implements part of the business logic with a javascript in the browser ... that is not secure and might not end well in some cases.

My opinion is that the browser code should be used only for usability requirements. And those use cases need also test, so +1 for cypress for helping on that.

Nevertheless the middleware / APIs should be tested directly, also for preventing those invalid input cases that the interface might never send, but that might break everything.