cypress-audit: Cannot destructure property 'errors' of 'object null' as it is null,

Before creating an issue, make sure to have setup the projects with the 3 steps provided in the README. You can also verify the examples folder and check if there is already an application using a similar setup to yours.

What does not work? Report not able to be generated. Error being thrown is: “Cannot destructure property ‘errors’ of ‘object null’ as it is null,” and it quotes line 41 at command-handler inside /src, where it reads: .then(({ errors, results })

How to reproduce? Setting up a basic, essentially empty test, as follows.

describe("empty test", () =>  {
    const retryOptions = {retries: {runMode: 0, openMode: 0}}
    it('runs an empty test', retryOptions, () => {
        cy.visit(*any url*)
        cy.lighthouse()
    })
})

index has what it’s supposed to:

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

inside of on.task:

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

and in commands: import "cypress-audit/commands";

Expected behavior Audit will be generated

Environment (please complete the following information):

  • OS: Mac OsX 12.01
  • Chrome version: 95.0.4638.69
  • Cypress version: 8.6

Any other information that may help fixing the issue? My inclination is that this is perhaps more a problem with cypress and the way it handles port assignment, or maybe another thing I bring up a bit further down, but I’m still creating this issue in case other people are running into the same when trying to incorporate cypress-audit for the first time. Also, this is the console.log of the lighthouse object. Seems relevant that config and opts are both undefined:

{
    "config": undefined
    "opts": undefined
    "url": "*any url*",
    "thresholds": {
        "performance": 100,
        "accessibility": 100,
        "best-practices": 100,
        "seo": 100,
        "pwa": 100
    }
}

My last bit of context is that ‘before:browser:launch’ doesn’t seem to be running- console.log-ing it, at least, doesn’t show anything. Again, this points to cypress being the problem, but I’m just curious if this has become an issue for anyone else.

About this issue

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

Most upvoted comments

Cypress 9.4.1 I have the same problem, firstly, the connection methods are indicated in the documentation, apparently outdated?
For example import “cypress-audit/commands”; - project import “@cypress-audit/pa11y/commands”; - example import “@cypress-audit/lighthouse/commands”; - example const { lighthouse, pa11y, prepareAudit } = require(“cypress-audit”); - project const { lighthouse, prepareAudit } = require(“@cypress-audit/lighthouse”); - example const { pa11y } = require(“@cypress-audit/pa11y”); - example

Previously, the package worked, now I get the same error, the list of packages: npm install cypress --save-dev npm install --save-dev cypress-audit npm install --save-dev cypress-image-snapshot (need force) npm install --save-dev cypress-terminal-report npm install --save-dev cypress-log-to-output

UPD - last package breaks audit

I have the same problem when using https://github.com/Shelex/cypress-allure-plugin together with cypress-audit. Are there any chances to bring them (or other plugins) together?

Update: If I switch to @cypress-audit/lighthouse I get following error:

cy.task('lighthouse') failed with the following error:
> port is not defined