realtebo's avatar

How to use Cypress.io to test a Laravel app?

I would like to give a try to Cypress to test a laravel ap..

Do you know a good tutorial about it?

A part this, I ask you how to accomplish the 'reset' of db before each test session. I thinks it's a common problem.

I have a dedicated test server with a dedicated db, so I can have a fresh copy of production with real data, then test my code in a real environment; now I register users, make orders, acting as admin I do steps to send goods to users, etc... I can do this already now after one day of studying Cypress...

But my question is ... how I can reset now my test environment for next test session without having to redploy the db?

or ... better ... is there a way to automatize db snapshotting and restore ? or similar strategies?

I cannot simply think of day by day , test by test, delete new roww before running new test session

0 likes
3 replies
bobbybouwmann's avatar

Cypress just talks to a URL. So, in theory, you can test any website that is available through a URL. So you can also use Cypress to test against your mail client as an example.

This tutorial should give you a good introduction in starting to test with Laravel: https://medium.com/@dimoff2000/end-to-end-testing-with-cypress-for-laravel-developers-25318b11a6fc

Cypress itself doesn't integrate with Laravel. So if you want to reset the database using a snapshot you need to build that yourself. You can, for example, make an artisan command for that and run that before you start running the cypress tests. That should already fix most of your questions ;)

1 like
realtebo's avatar

Usefull thanks. Could you illustrate with code/example what is "/_testing/login" ?

Please or to participate in this conversation.