{"id":28515061,"url":"https://github.com/percy/example-percy-playwright","last_synced_at":"2025-07-05T09:31:08.735Z","repository":{"id":42072664,"uuid":"419465058","full_name":"percy/example-percy-playwright","owner":"percy","description":"Example app showing integration of Percy visual testing into Puppeteer tests. ","archived":false,"fork":false,"pushed_at":"2025-06-11T19:59:27.000Z","size":288,"stargazers_count":1,"open_issues_count":2,"forks_count":5,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-07-03T12:57:23.034Z","etag":null,"topics":["percy","playwright","testing","visual-testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/percy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-20T19:32:24.000Z","updated_at":"2025-06-11T19:59:29.000Z","dependencies_parsed_at":"2024-06-19T23:34:36.129Z","dependency_job_id":"f7892992-8101-481c-82ad-16825f3d8e4b","html_url":"https://github.com/percy/example-percy-playwright","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/percy/example-percy-playwright","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percy%2Fexample-percy-playwright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percy%2Fexample-percy-playwright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percy%2Fexample-percy-playwright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percy%2Fexample-percy-playwright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/percy","download_url":"https://codeload.github.com/percy/example-percy-playwright/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/percy%2Fexample-percy-playwright/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263718250,"owners_count":23500799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["percy","playwright","testing","visual-testing"],"created_at":"2025-06-09T02:35:28.360Z","updated_at":"2025-07-05T09:31:08.730Z","avatar_url":"https://github.com/percy.png","language":"JavaScript","readme":"# example-percy-playwright\n\nExample app showing integration of [Percy](https://percy.io/) visual testing into Playwright tests.\n\nBased on the [TodoMVC](https://github.com/tastejs/todomvc) [VanillaJS](https://github.com/tastejs/todomvc/tree/master/examples/vanillajs)\napp, forked at commit\n[4e301c7014093505dcf6678c8f97a5e8dee2d250](https://github.com/tastejs/todomvc/tree/4e301c7014093505dcf6678c8f97a5e8dee2d250).\n\n## Playwright Tutorial\n\nThe tutorial assumes you're already familiar with JavaScript and\n[Playwright](https://playwright.dev/docs/library) and focuses on using it with Percy. You'll still\nbe able to follow along if you're not familiar with Playwright, but we won't\nspend time introducing Playwright concepts.\n\nThe tutorial also assumes you have [Node 14+ with\nnpm](https://nodejs.org/en/download/) and\n[git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) installed.\n\n### Step 1\n\nClone the example application and install dependencies:\n\n```bash\n$ git clone git@github.com:percy/example-percy-playwright.git\n$ cd example-percy-playwright\n$ npm install\n```\n\nThe example app and its tests will now be ready to go. You can explore the app\nby opening the\n[`index.html`](https://github.com/percy/example-percy-playwright/blob/master/index.html)\nfile in a browser.\n\n### Step 2\n\nSign in to Percy and create a new project. You can name the project \"todo\" if you'd like. After\nyou've created the project, you'll be shown a token environment variable.\n\n### Step 3\n\nIn the shell window you're working in, export the token environment variable:\n\n**Unix**\n\n``` shell\n$ export PERCY_TOKEN=\"\u003cyour token here\u003e\"\n```\n\n**Windows**\n\n``` shell\n$ set PERCY_TOKEN=\"\u003cyour token here\u003e\"\n\n# PowerShell\n$ $Env:PERCY_TOKEN=\"\u003cyour token here\u003e\"\n```\n\nNote: Usually this would only be set up in your CI environment, but to keep things simple we'll\nconfigure it in your shell so that Percy is enabled in your local environment.\n\n### Step 4\n\nCheck out a new branch for your work in this tutorial (we'll call this branch\n`tutorial-example`), then run tests \u0026 take snapshots:\n\n``` shell\n$ git checkout -b tutorial-example\n$ npm run test-web\n```\n\nThis will run the app's Playwright tests, which contain calls to create Percy snapshots. The snapshots\nwill then be uploaded to Percy for comparison. Percy will use the Percy token you used in **Step 2**\nto know which organization and project to upload the snapshots to.\n\nYou can view the screenshots in Percy now if you want, but there will be no visual comparisons\nyet. You'll see that Percy shows you that these snapshots come from your `tutorial-example` branch.\n\n### Step 5\n\nUse your text editor to edit `index.html` and introduce some visual changes. For example, you can\nadd inline CSS to bold the \"Clear completed\" button on line 32. After the change, that line looks\nlike this:\n\n``` html\n\u003cbutton class=\"clear-completed\" style=\"font-weight:bold\"\u003eClear completed\u003c/button\u003e\n```\n\n### Step 6\n\nCommit the change:\n\n``` shell\n$ git commit -am \"Emphasize 'Clear completed' button\"\n```\n\n### Step 7\n\nRun the tests with snapshots again:\n\n``` shell\n$ npm run test-web\n```\n\nThis will run the tests again and take new snapshots of our modified application. The new snapshots\nwill be uploaded to Percy and compared with the previous snapshots, showing any visual diffs.\n\nAt the end of the test run output, you will see logs from Percy confirming that the snapshots were\nsuccessfully uploaded and giving you a direct URL to check out any visual diffs.\n\n### Step 8\n\nVisit your project in Percy and you'll see a new build with the visual comparisons between the two\nruns. Click anywhere on the Build 2 row. You can see the original snapshots on the left, and the new\nsnapshots on the right.\n\nPercy has highlighted what's changed visually in the app! Snapshots with the largest changes are\nshown first You can click on the highlight to reveal the underlying screenshot.\n\nIf you scroll down, you'll see that no other test cases were impacted by our changes to the 'Clear\ncompleted' button. The unchanged snapshots appear grouped together at the bottom of the list.\n\n### Finished! 😀\n\nFrom here, you can try making your own changes to the app and tests, if you like. If you do, re-run\nthe tests  and you'll see any visual changes reflected in Percy.\n\n\n## Playwright with Automate Tutorial\n\nThe tutorial assumes you're already familiar with JavaScript and\n[Playwright](https://playwright.dev/docs/library) and focuses on using it with Percy. You'll still\nbe able to follow along if you're not familiar with Playwright, but we won't\nspend time introducing Playwright concepts.\n\nThe tutorial also assumes you have [Node 14+ with\nnpm](https://nodejs.org/en/download/) and\n[git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) installed.\n\nMinimum required `@percy/cli` version is `1.28.8-beta.3` for this to work correctly. If you already have `@percy/cli` or `@percy/webdriver-utils` installed please update it to latest or minium required version.\n\n\n### Step 1\n\nClone the example application and install dependencies:\n\n```bash\n$ git clone git@github.com:percy/example-percy-playwright.git\n$ cd example-percy-playwright\n$ npm install\n```\n\nThis tutorial specifically uses Browserstack Automate to run playwright test.\n\nFor automate you will need credentials so refer to following instructions to get the same\n\n1. You will need a BrowserStack `username` and `access key`. To obtain your access credentials, [sign up](https://www.browserstack.com/users/sign_up?utm_campaign=Search-Brand-India\u0026utm_source=google\u0026utm_medium=cpc\u0026utm_content=609922405128\u0026utm_term=browserstack) for a free trial or [purchase a plan](https://www.browserstack.com/pricing).\n\n2. Please get your `username` and `access key` from [profile](https://www.browserstack.com/accounts/profile) page.\n\n### Step 2\n\nSign in to Percy and create a new project. You can name the project \"PercyOnAutomateTest\" if you'd like. After\nyou've created the project, you'll be shown a token environment variable.\n\n### Step 3\n\nIn the shell window you're working in, export the token environment variable:\n\n**Unix**\n\n``` shell\n$ export PERCY_TOKEN=\"\u003cyour token here\u003e\"\n```\n\n**Windows**\n\n``` shell\n$ set PERCY_TOKEN=\"\u003cyour token here\u003e\"\n\n# PowerShell\n$ $Env:PERCY_TOKEN=\"\u003cyour token here\u003e\"\n```\n\nNote: Usually this would only be set up in your CI environment, but to keep things simple we'll\nconfigure it in your shell so that Percy is enabled in your local environment.\n\nSet the necessary BROWSERSTACK ENVIRONMENT variables\n\n**Unix**\n\n``` shell\n$ export BROWSERSTACK_USERNAME=\"\u003cyour browserstack user_name\u003e\"\n$ export BROWSERSTACK_ACCESS_KEY=\"\u003cyour browserstack access_key\u003e\"\n```\n\n**Windows**\n\n``` shell\n$ set BROWSERSTACK_USERNAME=\"\u003cyour browserstack access_key\u003e\"\n$ set BROWSERSTACK_ACCESS_KEY=\"\u003cyour browserstack access_key\u003e\"\n\n# PowerShell\n$ $Env:BROWSERSTACK_USERNAME=\"\u003cyour browserstack access_key\u003e\"\n$ $Env:BROWSERSTACK_ACCESS_KEY=\"\u003cyour browserstack access_key\u003e\"\n```\n\nAlternatively you can also update `USER_NAME`, `ACCESS_KEY` with Browserstack User name, Access key in the script as well.\n\n### Step 4\n\nConsidering all the above steps are done, we will run our tests, which will create automate session as well as percy build.\n\n``` shell\n$ npm run test-automate-before\n```\n\nYour **First Percy on Automate** build is created.\nOn completion of the script, you would be able to see the your percy build. Since we ran for the first time, we would see these are new screenshots and hence there would be no comparisons.\n\n### Step 5\n\nNow in order to make comparisons happen we need to make changes to the existing website so that a visual change can occur.\n\n``` shell\n$ npm run test-automate-after\n```\n\nOn completion of this script, this build would get compared to the previous build and hence we can see the visual changes which percy detected.\n\n### Finished! 😀\n\nFrom here, you can try making your own changes to the website and functional tests, if you like. If you do, re-run the tests and you'll see any visual changes reflected in Percy.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercy%2Fexample-percy-playwright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpercy%2Fexample-percy-playwright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercy%2Fexample-percy-playwright/lists"}