Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

troccoli's avatar

Cypress bug?

I think I may have found a bug in Cypress, but before raising a issue there I was wondering if maybe it's not really a bug and someone else has come up with a solution.

I was able to reproduce the issue with a brand new Laravel project with the Livewire+Blade Starter kit.

I have a test to make sure that a user can log in

t('should sing a user in', () => {
    cy.visit('/login')

    cy.get('[data-test-id="email"]').type('[email protected]')
    cy.get('[data-test-id="password"]').type('password')
    cy.get('[data-test-id="login"]').click()

    cy.location().should((loc) => {
        expect(loc.pathname).to.eq('/dashboard')
    })
})

As I said, I am using the default Starter Kit, the only thing I changed was adding the data-test-id to the blade component.

When using Cypress 14.0.3 the test passes. If I upgrade to 14.1.0 (the next release up) the test fails.

If I run npm run cy:open then I can see that the user is indeed redirected to the \dashboard but for some reason the location is still on \login.

I haven't tried all newer versions of Cypress, but on the latest one, which is 14.5.0 at the time of writing, the test still fails.

Does anybody have a clue what's going on? I think the test is pretty simple and straightforward, and so is the Livewire component. Has anybody found this issue? Or nobody tests the logging-in these days...

0 likes
2 replies
LaryAI's avatar

This is a great, detailed report! What you’re running into is a known issue with Cypress 14.1.0+ (especially with Firefox), Livewire, and how Cypress handles network requests and page navigation. Here’s what’s happening and how you can work around it:

What's Happening?

  • Livewire uses AJAX requests for form submissions.
  • Cypress 14.1.0+ introduced changes to how it intercepts and manages network requests, especially with Firefox.
  • After clicking the login button, Livewire sends an AJAX request. If the login is successful, the server responds with a redirect, and Livewire updates the page.
  • Cypress may not detect the navigation as a "real" page load, so cy.location() might not update as expected.
  • The JSON parse error is likely because Cypress is interfering with or double-intercepting Livewire's AJAX requests, causing malformed responses.

Solutions

1. Use cy.url().should('include', '/dashboard') Instead

Sometimes, cy.location() can be less reliable with Livewire. Try:

cy.url().should('include', '/dashboard')

2. Add a Wait for the Dashboard Content

Instead of relying solely on the URL, assert that dashboard content is present:

cy.get('[data-test-id="dashboard-content"]').should('be.visible')

Make sure you add a unique data-test-id to something on your dashboard page.

3. Ignore Uncaught Exceptions (Temporary Workaround)

You can tell Cypress to ignore these exceptions, so your test doesn't fail due to Livewire's AJAX errors:

Cypress.on('uncaught:exception', (err, runnable) => {
  // Ignore Livewire JSON parse errors
  if (err.message.includes('JSON.parse')) {
    return false
  }
})

Add this to your cypress/support/e2e.js or cypress/support/index.js.

4. Use Chrome Instead of Firefox

This issue is more prevalent in Firefox. Try running your tests in Chrome:

npx cypress run --browser chrome

5. Downgrade to Cypress 14.0.3

If the above workarounds don't suit you, stick with 14.0.3 until the Cypress team resolves this regression.


Example Test (with Workarounds)

Cypress.on('uncaught:exception', (err, runnable) => {
  if (err.message.includes('JSON.parse')) {
    return false
  }
})

it('should sign a user in', () => {
  cy.visit('/login')

  cy.get('[data-test-id="email"]').type('[email protected]')
  cy.get('[data-test-id="password"]').type('password')
  cy.get('[data-test-id="login"]').click()

  // Wait for dashboard content, not just URL
  cy.get('[data-test-id="dashboard-content"]').should('be.visible')
  cy.url().should('include', '/dashboard')
})

References


Summary:
This is a Cypress regression with Livewire and AJAX navigation. Use the workarounds above, and consider reporting your findings to the Cypress team with a minimal reproduction if you haven't already. You're not alone—many are running into this with Livewire and SPA-like navigation!

troccoli's avatar

The only solution that works, from the one suggested by @laryai, is to ignore the exception, which obviously I don't want to do.

Please or to participate in this conversation.