Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percy not capturing any snapshots (fails to find healthcheck) #61

Closed
stijnbernards opened this issue Mar 19, 2019 · 42 comments
Closed

Percy not capturing any snapshots (fails to find healthcheck) #61

stijnbernards opened this issue Mar 19, 2019 · 42 comments

Comments

@stijnbernards
Copy link

stijnbernards commented Mar 19, 2019

Hi

I'm trying to integrate Percy and Cypress for one of my projects.
Sadly Percy doesn't seem to take any snapshots even though I'm calling cy.percySnapshot multiple times.

This is my current test:

describe('Magento tests', () => {
  beforeEach(() => {
    cy.visit(Cypress.env('staging-url'))
  })

  it('Should allow a product to be ordered', () => {
    cy.percySnapshot('Homepage')

    // Forcing due to sticky headers messing up the click area
    cy.get('nav.navigation > ul > li:first-of-type a')
        .click({ force: true })

    cy.percySnapshot('Category - Boxsprings')

    cy.get('.products.list.items.product-items')
        .find('li:first-of-type a.product-item-link')
        .click()

    cy.percySnapshot('Product page')
  })
})

This is my Cypress result:
image

UPDATE: Seems like percy is unable to capture screenshots on https websites. Is this correct?
This is quite a showstopper for the current project I'm integrating it for.

@Robdel12
Copy link
Contributor

Hi there!

Percy can capture HTTPS websites. This seems a lot like there's CSP or CORS issues on the page blocking us from POSTing the DOM back to our node process. Can you try disabling Cypress web security and give it another shot?

@stijnbernards
Copy link
Author

Hi, thank you for your response.

This does indeed seem to fix it.
Would be nice if we're able to get error logging about this issue.
I did see the part in the Percy Cypress docs about the websecurity.
But I did not receive any error logging at all :(

@GordonTester
Copy link

GordonTester commented Mar 27, 2019

I'm seeing an issue with Percy not taking screenshots within my Cypress project. I've tried to point the tests to both a https and non https site and each time the tests pass in Cypress but fail within the Percy Dash as it was unable to find any screenshots.

When I run via chrome (and the cy GUI opens locally) I can see that the percy agent healthcheck is failing for some reason...

Any advice?

I am running my test using a script, as such:

"cy:run:percy": "export TEST_SUITE=foo; PERCY_TOKEN=xxx PERCY_BRANCH=test percy exec -- cypress run",

I can see it running in the terminal, bookended by percy calls

[percy] percy has started / ended etc....

@mapsandapps
Copy link

Hi @GordonTester, I had the same issue and downgrading to version 1.0.2 fixed it for me.

@Robdel12
Copy link
Contributor

Hey all! We had an issue with the 1.0.3 release but it should be fixed with 1.0.4. Can you give it a try and let us know? https://github.com/percy/percy-cypress/releases/tag/v1.0.4

@mapsandapps
Copy link

@Robdel12 I did try 1.0.4, and I had the same issue as with 1.0.3.

@Robdel12
Copy link
Contributor

Can you share a little more about your setup? I'd be curious if there's any error logs or anything we can learn from what's going on there.

@ericz82
Copy link

ericz82 commented Mar 28, 2019

1.0.4 works for me. Looks like the healthcheck path fix did the trick!

@mapsandapps
Copy link

I think that perhaps it is because we are using webpack, and require.resolve is returning a number instead of a path, similar to this issue.

@Robdel12 Robdel12 changed the title Percy not capturing any snapshots Percy not capturing any snapshots (fails to find healthcheck) Apr 9, 2019
@Robdel12
Copy link
Contributor

Robdel12 commented Apr 9, 2019

I believe this is safe to close now. If anyone sees any more issues with the healthcheck failing please comment and we'll reopen 👍

@amrwahdan3
Copy link

amrwahdan3 commented Jul 16, 2019

hello i am getting this issue. i dont get any snapshots and i get this error:
'Percy agent is not running. Skipping snapshots'

im running 3.3.2, my baseUrl in cypress.json is a https if that matters and i have the "chromeWebSecurity": false.
my tests are pretty basic:

describe('desktop home page tests', function () {

	beforeEach('SetUp', function () {
		cy.visit('/?flagoverride=flag1::true,flag2::false')
	})

	context('Desktop_Homepage_LayoutCorrect', function () {
		it('The layout is correct.', function () {
			cy.percySnapshot('Desktop Homepage')
		})
	})
})

this is also is the log:
[33m»�[39m Warning: �[33mhealth-check�[39m is not a percy command.↵Did you mean �[94mexec�[39m? [y/n]:

it happens in chrome and electron browser.

thanks

@Robdel12
Copy link
Contributor

Robdel12 commented Jul 17, 2019

Hey @amrwahdan3! It sounds like you're running an old version of @percy/agent with a new version of the Cypress SDK. Could you do an npm ls @percy/agent and post what the results of that are? v0.2.0 is when the healthcheck command was implemented: https://github.com/percy/percy-agent/blob/master/CHANGELOG.md#020-2019-04-03

Edit: I looked at one of your builds and can confirm that you're running @percy/agent 0.1.15

@amrwahdan3
Copy link

amrwahdan3 commented Jul 17, 2019

thanks @Robdel12 ! that did the trick i see snapshots being taken and uploaded now after updating to 0.8.3

@james-hughes-ntt
Copy link

I'm seeing the same issue that @amrwahdan3 was seeing.

[percy] stopping percy...
[percy] waiting for 0 snapshots to complete...
[percy] done.

I have the following setup:

  • @percy/agent
npm ls @percy/agent
cy-visual-tests@1.0.0 /Users/hughej/Projects/Personal/JavaScript/Cypress/cy-visual-tests
└─┬ @percy/cypress@2.3.1
  └── @percy/agent@0.28.1 
  • package.json dependencies
"dependencies": {
    "@percy/cypress": "^2.3.1",
    "cypress": "^4.9.0",
    "cypress-image-snapshot": "^3.1.1",
    "prettier": "^2.0.5"
  }
  • cypress.json
{
    "video": false,
    "defaultTimeoutCommand": 5000,
    "pageLoadTimeout": 10000,
    "waitForAnimations": true,
    "chromeWebSecurity": false
}

Any help would be greatly appreciated. Thanks!

@amrwahdan3
Copy link

@james-hughes-ntt i updated @percy/agent to the newest version like @Robdel12 suggested and that ended up working.

@james-hughes-ntt
Copy link

james-hughes-ntt commented Sep 3, 2020

Thanks. So after running npm ls @percy/agent it shows that I'm using @percy/agent@0.28.1 which appears to be the newest version. Not sure what else to try 🤷‍♂️

@Robdel12
Copy link
Contributor

Robdel12 commented Sep 3, 2020

I don't believe this is a health check issue (unless you're seeing that specific log in Cypress command log). What test is calling cy.percySnapshot? Are there any logs around that?

@james-hughes-ntt
Copy link

james-hughes-ntt commented Sep 3, 2020

@Robdel12 I'm running percy exec -- cypress run
Here's the log from running that:

percy exec -- cypress run

[percy] created build #18 ...
[percy] percy has started.

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    4.9.0                                                                              │
  │ Browser:    Electron 80 (headless)                                                             │
  │ Specs:      1 found (percy.spec.js)                                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    
  Running:  percy.spec.js                                                                   (1 of 1)


  Visual Regression Testing with Percy and Cypress
    ✓ should take a percy snapshot (1295ms)


  1 passing (4s)


  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      1                                                                                │
  │ Failing:      0                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        false                                                                            │
  │ Duration:     3 seconds                                                                        │
  │ Spec Ran:     percy.spec.js                                                                    │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


====================================================================================================

  (Run Finished)


       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  percy.spec.js                            00:03        1        1        -        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        00:03        1        1        -        -        -  

[percy] stopping percy...
[percy] waiting for 0 snapshots to complete...
[percy] done.

@Robdel12
Copy link
Contributor

Robdel12 commented Sep 4, 2020

Just to be 100% sure, what is the code for that test?

@james-hughes-ntt
Copy link

Yeah good shout @Robdel12 . Pretty standard test.

describe('Visual Regression Testing with Percy and Cypress', () => {
    it('should take a percy snapshot', () => {
        cy.visit('https://www.example.com');
        cy.wait(1000);
        cy.percySnapshot;
    });
});

@Robdel12
Copy link
Contributor

Robdel12 commented Sep 8, 2020

Hey @james-hughes-ntt, thanks for that! Looks like you're missing the parens to invoke the function:

describe('Visual Regression Testing with Percy and Cypress', () => {
    it('should take a percy snapshot', () => {
        cy.visit('https://www.example.com');
        cy.wait(1000);
        cy.percySnapshot();
    });
});

@james-hughes-ntt
Copy link

james-hughes-ntt commented Sep 8, 2020

@Robdel12 ah thanks mate, yeah that was it! So duh of me. I was looking at all the places except for the most obvoius - where percy is actually invoked! Thanks again appreciate the help

@Robdel12
Copy link
Contributor

Robdel12 commented Sep 8, 2020

Ahhh, no worries! This happens to me all the time when doing support too. I get too far off in the weeds and it turns out it was something obvious :p

Happy it was something easy rather than something like the health check failing :D

@Uraz04
Copy link

Uraz04 commented Feb 3, 2021

Hey there. Seems like I'm having the same issue as @james-hughes-ntt and I've checked the parens etc within the code but all seems fine (to me that is)..the below is the output and I can see something about the certificate but not sure if that's the issue. Also, disabled websecurity for chrome in the cypress.json file.

cypress_snapshot@1.0.0 cy:percy
percy exec -- cypress run

[percy] RequestError Error: self signed certificate in certificate chain | Wed Feb 03 2021 20:58:22 GMT+0000 (Greenwich Mean Time)
[percy] stopping percy...
[percy] waiting for 0 snapshots to complete...
[percy] done.
[percy] percy has started.

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 6.3.0 │
│ Browser: Electron 87 (headless) │
│ Specs: 3 found (percy.spec.js, percy2.spec.js, Snapshot/image.spec.js) │
└────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

Running: percy.spec.js (1 of 3)

Visual Regression test with Percy and Cypress
✓ should take percy snapshot (4559ms)

1 passing (6s)

(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: false │
│ Duration: 6 seconds │
│ Spec Ran: percy.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

Running: percy2.spec.js (2 of 3)

Visual Regression test with Percy and Cypress
✓ should take percy snapshot (3277ms)

1 passing (4s)

(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: false │
│ Duration: 4 seconds │
│ Spec Ran: percy2.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

Running: Snapshot/image.spec.js (3 of 3)

0 passing (0ms)

(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 0 │
│ Passing: 0 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: false │
│ Duration: 0 seconds │
│ Spec Ran: Snapshot/image.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘

====================================================================================================

(Run Finished)

   Spec                                              Tests  Passing  Failing  Pending  Skipped  

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ percy.spec.js 00:06 1 1 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ✔ percy2.spec.js 00:04 1 1 - - - │
├────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ✔ Snapshot/image.spec.js 2ms - - - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! 00:10 2 2 - - -

[percy] stopping percy...
[percy] waiting for 0 snapshots to complete...
[percy] done.

@Robdel12
Copy link
Contributor

Robdel12 commented Feb 4, 2021

Hey @Uraz04, it looks like you're running on a network with a self signed cert (this won't work with Percy)

[percy] RequestError Error: self signed certificate in certificate chain

@tinganho
Copy link

@Robdel12 I have tried to get Percy taking snapshot as well in Cypress. Tried all the above, and no missing parens. Also disabled web security. The only thing I can see is this:

image

@tinganho
Copy link

image

@Robdel12
Copy link
Contributor

What version are you using? This likely isn't related to this issue. The latest version of the SDK doesn't have a health check like this anymore.

@Robdel12
Copy link
Contributor

Also, the log there suggests Percy isn't running. Are you using percy exec -- cypress run with a PERCY_TOKEN set?

@tinganho
Copy link

I'm running with these versions:
image

image

@tinganho
Copy link

You disregard that font log. It doesnt work with a proper font as well.

@Robdel12
Copy link
Contributor

Can you set --verbose (npx percy exec --verbose -- ...) for debug logs? Looks like the network request to http://localhost:5338/percy/snapshot is failing for some reason. Curious if it's related to Cypress's 7.x networking bug in a different flavor. 🤨

@tinganho
Copy link

tinganho commented Apr 21, 2021

@Robdel12 I cannot add that flag?

image

I tried before exec command as well

@Robdel12
Copy link
Contributor

Robdel12 commented Apr 21, 2021

which percy? Smells like you have @percy/agent hanging around somewhere. --verbose is a new @percy/cli flag (and @percy/agent is replaced by @percy/cli)

@tinganho
Copy link

Seems to work now. Just deleted node_modules and reinstalled everything. Thanks!

@stuthib
Copy link

stuthib commented Sep 22, 2021

Hi, I am running into a missing snapshot issue. It is not consistent and I can't figure out the cause. I ran the command with --verbose and see this error.
Cypress: 6.9.1
"@percy/cli": "^1.0.0-beta.63"
"@percy/cypress": "^3.1.1"

     [percy:core] Error: Navigation failed: Timeout of 30000ms exceeded.
    at Timeout.check [as _onTimeout] (/node_modules/@percy/core/dist/utils.js:103:17)
    at listOnTimeout (node:internal/timers:559:11)
    at processTimers (node:internal/timers:500:7) (0ms)```

Any help would be much appreciated! 

@Robdel12
Copy link
Contributor

Hey @stuthib! That doesn't appear to be related to what this issue was about. Can you try upgrading @percy/cli to the latest (beta.68) and if that still is a problem open a new discussion on @percy/cli?

@stuthib
Copy link

stuthib commented Sep 23, 2021

@Robdel12 Thank you for the quick response. I updated @percy/cli and also set the timeout in percy config to 60000, while the default was 30000 and it was timing out on page navigation. The last few builds have not errored out and seems to be consistent. If I run into this issue again, I will open a new discussion on @percy/cli.

@skareemu
Copy link

skareemu commented Dec 7, 2021

@Robdel12 I am also running into the same issue. When I do --verbose, it says the below.

[percy:cypress] Could not take DOM snapshot "Dashboard Page" (36154ms)
[percy:cypress] Error: Missing required URL for snapshot
at request (https://customer.nintex.com/__cypress/tests?p=cypress\support\index.js:784:28)
at async Object.postSnapshot (https://customer.nintex.com/__cypress/tests?p=cypress\support\index.js:895:6) (5ms)

When I researched further, I came to know that it is working fine in my personal laptop, however in my company laptop it is not working. It appears like from my company laptop it is failing to connect to percy server or failing to get the build url or something like that. Appreciate if you could please look into it and advise me to resolve this issue. Please see complete console log below

---------------------------Here is the complete console log------------------
npx percy exec --verbose -- cypress run
[percy:config] Config file not found (0ms)
[percy:client] Creating a new build... (27ms)
[percy:core:browser] Launching browser (491ms)
[percy:core:browser] Browser connected: HeadlessChrome/92.0.4515.0 (117ms)
[percy:core] Percy has started! (3ms)
[percy:cli:exec] Running "cypress run" (0ms)

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 9.1.0 │
│ Browser: Electron 94 (headless) │
│ Node Version: v16.13.1 (C:\Program Files\nodejs\node.exe) │
│ Specs: 1 found (visual_testing/purek2.spec.js) │
└────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

Running: visual_testing/purek2.spec.js (1 of 1)
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating

Customer Central-Visual Testing
[percy:cypress] Could not take DOM snapshot "Dashboard Page" (36154ms)
[percy:cypress] Error: Missing required URL for snapshot
at request (https://customer.nintex.com/__cypress/tests?p=cypress\support\index.js:784:28)
at async Object.postSnapshot (https://customer.nintex.com/__cypress/tests?p=cypress\support\index.js:895:6) (5ms)
√ Pure K2 Permission checks - Dashboard Page (27854ms)

1 passing (28s)

(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 1 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 0 │
│ Skipped: 0 │
│ Screenshots: 0 │
│ Video: true │
│ Duration: 27 seconds │
│ Spec Ran: visual_testing/purek2.spec.js │
└────────────────────────────────────────────────────────────────────────────────────────────────┘

(Video)

  • Started processing: Compressing to 32 CRF
  • Finished processing: C:\Work\ntx_appdevit_automation\ncc_automation\cypress\vide (3 seconds)
    os\visual_testing\purek2.spec.js.mp4

====================================================================================================

(Run Finished)

   Spec                                              Tests  Passing  Failing  Pending  Skipped  

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ √ visual_testing/purek2.spec.js 00:27 1 1 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
√ All specs passed! 00:27 1 1 - - -

[percy:core:browser] Closing browser (4392ms)
[percy:client] Finalizing build 14402721... (135ms)
[percy:core] Finalized build #13: https://percy.io/3f3a16fc/ncc_automation/builds/14402721

@Robdel12
Copy link
Contributor

Robdel12 commented Dec 7, 2021

Hey @skareemu! Upgrade Cypress from 9.1 to 9.1.1: #437 (reply in thread) v9.1 has missing patched dependencies, which makes for some wonky bugs.

@skareemu
Copy link

skareemu commented Dec 7, 2021

Thank you so much @Robdel12, much appreciated . Issue is resolved with 9.1.1

@NikitaSheff
Copy link

Same issue with Cypress v13.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests