Posts

Showing posts from 2025

Cypress Connection Refused Error

 I had a case where I need to call an api then visit the app in Cypress and it turns out to be causing an issue with the following error message: Error: connect ECONNREFUSED 127.0.0.1:4200 It turns out to be Cypress' origin safety issue. I wrapped the cy.request() with cy.origin() and that solves the issue with a catch. If I call cy.origin() before I call cy.visit() then it doesn't work somehow. If I call cy.visit() first and then cy.origin() then it works fine. Also, if after code change, it doesn't appear to work, restart cypress app (or test runner if using older version).  I had the case where I call cy.origin() first, then cy.visit() which doesn't work, make the change to call cy.visit() first without restarting the app and it still doesn't work. But it works after I restarted cypress app.

Playwright Intermittent Connection Refused Error

As I have more tests in Playwright, the number of workers required grow and I happened to encounter the following error: Error: page.goto: NS_ERROR_CONNECTION_REFUSED And the tests that failed changes every time playwright test is run. To solve this, I reduce the workers in playwright.config.ts. from: workers: process.env.CI ? 1 : undefined, to: workers: process.env.CI ? 1 : 8, //8 works fine for me. I will go smaller like 4 or 5 if the issue persists. This defines the max workers Alternatively, workers can be set when running the test. npx playwright test --workers 8 For more information: https://playwright.dev/docs/test-parallel#limit-workers