Cypress/percy authorization failed

198 Views Asked by At

I have one question to cypress/percy. I use Cypress package version: 12.5.1, Percy:@percy/cli 1.20.0, php version PHP 8.1.16 (cli). I have one project with authentication and have to do snapshots with Percy. I have tried to use username and password in the method cy.percySnapshot():

cy.visit('url');
cy.percySnapshot('name', {
    authorization: {
        username: '**********',
        password: '*********'
    }
});

My errors:

[percy] Invalid snapshot options: [percy] - authorization: unknown property

CypressError: cy.visit() failed trying to load: The response we received from your web server was:

401: Unauthorized

This was considered a failure because the status code was not 2xx.

If you do not want status codes to cause failures pass the option: failOnStatusCode: false

My package.json:

  "devDependencies": {
    "@percy/cli": "^1.20.0",
    "@percy/cypress": "^3.1.2",
    "cypress": "^12.5.1"
  },

Snapshot is in the directory in percy but without css.

Has anyone else had such problems?

Thank you in advance for your help. If you need more information, let me know.

1

There are 1 best solutions below

0
On

I have contacted percy support and have got following answer:

cy.percySnapshot("Homepage responsive test", {
  discovery: {
    requestHeaders: {
      Authorization: "Basic ${Buffer.from('username:password').toString('base64')}"
    }
  }
});