|

Embracing Cypress for Comprehensive Testing

May 3, 2025

Cypress Testing End to End

This week has been all about refining the testing strategy for my Laravel + Vue + Inertia app—and honestly, it’s been one of those productive deep-dives that makes you wonder why you didn’t do it sooner. I decided to go all-in on Cypress, exploring both end-to-end (E2E) and component testing capabilities.

And spoiler alert: I’m not looking back at Laravel Dusk.


Why Cypress?

When I first started working with Laravel, Dusk seemed like the natural choice for browser testing. It integrates well with Laravel and can simulate user interactions. But as soon as I brought Vue and Inertia into the mix, things started to feel… clunky. Dusk is tightly coupled to Laravel’s backend, and working with modern, dynamic frontends became increasingly brittle.

Cypress offered me what Dusk didn’t:

  • Frontend-first testing, which aligns beautifully with Vue components and SPA behavior.

  • Visual feedback: The Cypress Test Runner shows you exactly what's happening in your app as the test runs.

  • Fast dev loop: Changes are picked up instantly with auto-reload and no need to recompile the full Laravel app.

  • Powerful debugging: You can time-travel through your test steps, inspect the DOM, and pinpoint exactly where things go wrong.

End-to-End Testing: Simulating Actual User Flows

I set up tests for full user journeys like:

  • Logging in

  • Navigating to a dashboard

  • Creating a resource (e.g., a post)

  • Logging out

With Cypress, I could stub API calls or hit my backend directly depending on the scenario. The ability to easily mock auth states or use actual logins with cy.request() opened up so many possibilities Dusk made painful.

Example:

Screenshot 2025-05-03 at 13.17.51

It’s readable, runs fast, and tells me exactly what went wrong when things fail.

Component Testing: Testing Vue Bits in Isolation

I’m using Vue/Nuxt 3 (with Vite), and Cypress has a built-in mode for mounting individual components without spinning up the full app.

Testing things like a Modal.vue or Button.vue component became as simple as:

Screenshot 2025-05-03 at 13.18.35

This gave me quick feedback without needing to navigate through my app’s UI or backend. I could catch layout or logic bugs directly at the component level.

Cypress vs Laravel Dusk

Here’s a breakdown of how Cypress compares to Dusk from my personal experience:

Feature

Laravel Dusk

Cypress

Frontend integration

Poor

Excellent

Vue/SPA support

Limited

Native

Live reloading

No

Yes

Debuggability

Console logs

Time travel UI

Speed

Slower

Faster

Mocking/Interception

Difficult

Easy with

cy.intercept()

I still think Dusk has its place—like for backend-heavy flows or where you want to test actual browser behavior end-to-end in a true Laravel context. But for any serious Vue-heavy app, Cypress just feels like the tool Laravel didn’t know it needed.

Why It Matters

As developers, we often skip tests when the tools don’t feel intuitive. That was me with Dusk. But Cypress made testing feel like part of the dev workflow rather than a chore. And the confidence I’ve gained by knowing both my components and entire flows are solid? Game-changing.

If you're building apps with Laravel + Vue + Inertia—or really any modern frontend—Cypress is worth your time.

This week was just the start. I’ve already planned more tests, more component coverage, and even experimenting with CI integration next.

Happy testing 👨‍💻

© 2025, WattsUp. All rights reserved.