This sample repo demonstrates:
- A simple static app with a page that uses valid 3rd-party assets (
public/valid.html) - A page with intentionally broken 3rd-party assets (
public/broken.html) - Playwright tests that call Percy snapshots for both pages
- A minimal Express static server (server.js)
- Install deps:
npm install npm install --save-dev @percy/cli npx percy --version. #checking the version - Start the static server (in one terminal):
npm start # server runs at http://localhost:3000 - In another terminal run Percy-enabled Playwright tests:
- Make sure you have a Percy project and set the
PERCY_TOKENenvironment variable. - Run:
npx percy exec -- npx playwright test - Make sure you have a Percy project and set the
Valid assets pagesnapshot: should render correctly if external font & image are reachable.Broken assets pagesnapshot: external font and image are broken (404), so page rendering will be affected. Percy will capture the page as rendered in the browser; resources returning 404 will not be proxied into Percy snapshots.
- Run the failing/broken snapshot and capture Percy CLI logs:
(On Windows use
export PERCY_LOGLEVEL=debug npx percy exec -- npx playwright testset PERCY_LOGLEVEL=debugin CMD.) - Inspect the debug output — the
proxymap entries will show which asset URLs were proxied and which returned 404s. - To verify rendering locally, open Chrome, load the page, open DevTools -> Network -> Right-click -> "Capture full size screenshot" to verify CSS/asset rendering.
public/valid.html— valid assetspublic/broken.html— intentionally broken asset URLstests/percy.spec.js— Playwright tests with Percy snapshotsserver.js— static serverplaywright.config.js— Playwright config.percy-support.npmrc— sample (replace with your token if using npm registry for percy support)
- You can modify
public/broken.htmlto toggle which assets are broken. - This sample is intentionally simple so you can inspect how Percy treats third-party assets that 404.