cypress-audit: cy.task('lighthouse') failed with the following error: > connect ECONNREFUSED 127.0.0.1:61216

Hi, I did all the steps from readme and I am using plain JS but still I get the error like:

cy.task('lighthouse') failed with the following error:

> connect ECONNREFUSED 127.0.0.1:61216

chrome_Qr7t4JPgGn

my package.json:

    "cypress": "^6.3.0",
    "cypress-audit": "^0.3.0",
    "cypress-file-upload": "^4.1.1",
    "cypress-sql-server": "^1.0.0",

Maybe I am missing some necessary step.

I have

const { lighthouse, pa11y, prepareAudit } = require('cypress-audit');

and

on('before:browser:launch', (browser = {}, launchOptions) => {
    prepareAudit(launchOptions);
  });

and

lighthouse: lighthouse(), // calling the function is important
   pa11y: pa11y(), // calling the function is important

in my plugins/index.js

And I have imported audit in support/commands:

import 'cypress-audit/commands';

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 28 (8 by maintainers)

Most upvoted comments

@mfrachet do you have or do you plan any update on the plugin? Doesn’t seem to work anymore with the most recent Cypress versions.

All working for me as well with cypress 6.4.0 in headless & normal modes. Thanks Marvin, this is a really great plugin, I love that I can now do my GUI, API, AND Performance testing all in one tool. Nice one 😃

I’m also having this issue on cypress 9.5.0 chrome 99

Same issue over here until i switched over to Edge. Hope, that may help someone out there… 😃

With cypress 6.4 it is working. Although in my case an extra tab was opened and closed while doing the the task. Is this normal?

Forgive my ignorance if I’m really missing something, but why not (also?) allow the test to run on a desired url or use the config baseUrl? Can it only run on localhost IP?

it("should pass the audits", function () {
    cy.visit('my-test-url');
    cy.lighthouse();
    cy.pa11y();
  });

And what about headless? I’m trying to use this after deploying to test environments with CI.

This is not a JS project. I just want to test pages, regardless of how they’re built.

I didn’t see anything in the docs to help me solve this. If that’s not what this package should do, I apologize for misunderstanding.

I have found something… i am running cypress with Chrome… I changed to Electron 87 and the test worked image

I did not… it skipped the test

I was facing the same issue and I was able to circumvent it by downgrading node from 18.x to 16.x.

Surely, it’s not a long term fix, but it’s a bandaid that unblocked me, at least for now.

Happy we managed to find something to fix this 😅 .

I’m closing this issue, feel free to reopen or comment if necessary 👍🏻

Thanks for your help 😊

It is 😊 . it’s the tab opened by lighthouse

Thank you for your feedbacks.

I’ve updated Cypress on 6.4 and it looks working now. Here’s the changelog: https://github.com/cypress-io/cypress/releases and here’s the potential bugfix:

Reverted a change to how the Chrome DevTools Protocol is established. Instead of using stdio and then falling back to TCP, Cypress now only uses TCP to try to connect to Chrome DevTools Protocol. Addresses #14819.

Can you confirm that it works for you when using Cypress 6.4?