percy / percy-cypress

Visual testing with Cypress and Percy
https://percy.io
MIT License
340 stars 41 forks source link

How to load external assets #99

Closed MatthD closed 4 years ago

MatthD commented 5 years ago

Hi, I am using percy-cypress with a symfony4/ webpack app, in developpement mod assets are not on the same port as the main app, so assets are not loaded by percy which make screenshot not usable.

What is the correct way to deal with those kind of app?

Robdel12 commented 4 years ago

Hi there!

If you're on the latest SDK version (v2.2.0) you can specify hostnames you would like Percy to capture when taking snapshots.

That could look something like: percy exec -h localhost -- cypress run or in the .percy.yml:

version: 1
agent:
  asset-discovery:
    allowed-hostnames:
      - localhost

This is a work around imo. Keep an eye on this PR: https://github.com/percy/percy-agent/pull/355 and you will probably be able to remove localhost from the hostname config. What's happening is we're currently taking the port into account for our rootResourceURL (where the snapshot is coming from). By default, we only capture assets from where the snapshot is coming from. And since we take the port into account at the moment, it will ignore assets on a different localhost port.