Skip to content

Cypress fails with JSON.parse: unexpected character at line 1 column 1 of the JSON data #31937

Open
@troccoli-sgr

Description

@troccoli-sgr

Current behavior

I have simple test which works on Cypress 14.0.3 and fails on Cypress 14.1.0 and 14.5.0 (I haven't tried all the other versions).

SyntaxError: The following error originated from your application code, not from Cypress. It was caused by an unhandled promise rejection.

  > JSON.parse: unexpected character at line 1 column 1 of the JSON data

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

Although it says the error originated from my application, the code has not change. I was only tried to upgrade Cypress.

Desired behavior

The test should pass as it did before, since the code has not changed.

Test code to reproduce

I'm using Laravel and Livewire and I was able to reproduce the issue with the following steps:

  1. create a brand new Laravel application
    laravel new --livewire --pest --npm example-app
  2. change into the new project's directory
    cd example-app
  3. install Cypress
    npm install cypress --save-dev
  4. create the configuration file
    npx cypress open --e2e
  5. add the base URL to cypress.config.js
    baseUrl: "http://localhost:8000"
  6. create a user for the test
    php artisan tinker --execute="App\Models\User::factory()->create(['email' => 'test@example.com']);"
  7. create the directory for the Cypress tests
    mkdir cypress/e2e
  8. create the Cypress test cypress/e2e/login.cy.js
it('should sing a user in', () => {
    cy.visit('/login')

    cy.get('[type="email"]').type('test@example.com')
    cy.get('[type="password"]').type('password')
    cy.get('[type="submit"]').click()

    cy.location().should((loc) => {
        expect(loc.pathname).to.eq('/dashboard')
    })
})
  1. in another terminal, run a PHP server
cd example-app
composer dev
  1. finally, run Cypress
    npx cypress run --browser firefox

Cypress Version

14.5.0

Node version

v22.16.10

Operating System

Mac Sequoia Version 15.5 (24F74)

Debug Logs

Other

This happens with Firefox 139. It works fine with Chrome 137, Edge 137, and Electron 130

I've tried to get the debug log with DEBUG=cypress:* npx cypress run --browser firefox but the log is too big to paste into the issue (Field can not be longer than 65536 characters). I know I can target the log, but I don't know what would be useful. Please let me know if you some specific logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions