{"id":17489243,"url":"https://github.com/dfinity/internet-identity-playwright","last_synced_at":"2026-02-11T10:02:47.253Z","repository":{"id":245812353,"uuid":"813137395","full_name":"dfinity/internet-identity-playwright","owner":"dfinity","description":"A Playwright library to simplify the integration of Internet Identity authentication in E2E tests.","archived":false,"fork":false,"pushed_at":"2026-01-31T07:35:27.000Z","size":786,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-01-31T07:36:46.568Z","etag":null,"topics":["e2e","icp","internet-computer","playwright","testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dfinity.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-10T14:43:47.000Z","updated_at":"2026-01-30T16:02:35.000Z","dependencies_parsed_at":"2024-06-24T10:08:56.858Z","dependency_job_id":"5c9581f0-b2c6-4cbe-9a95-8ac0668350b9","html_url":"https://github.com/dfinity/internet-identity-playwright","commit_stats":{"total_commits":49,"total_committers":3,"mean_commits":"16.333333333333332","dds":"0.24489795918367352","last_synced_commit":"faf4b71c78f8453fe74d5819591fdcb997d41837"},"previous_names":["dfinity/internet-identity-playwright"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/dfinity/internet-identity-playwright","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Finternet-identity-playwright","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Finternet-identity-playwright/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Finternet-identity-playwright/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Finternet-identity-playwright/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dfinity","download_url":"https://codeload.github.com/dfinity/internet-identity-playwright/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfinity%2Finternet-identity-playwright/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29331605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T06:13:03.264Z","status":"ssl_error","status_checked_at":"2026-02-11T06:12:55.843Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["e2e","icp","internet-computer","playwright","testing"],"created_at":"2024-10-19T05:06:23.120Z","updated_at":"2026-02-11T10:02:47.247Z","avatar_url":"https://github.com/dfinity.png","language":"TypeScript","readme":"# 🔐 Internet Identity Playwright\n\nA [Playwright](https://playwright.dev/) library to simplify the integration of [Internet Identity](https://identity.internetcomputer.org) authentication in E2E tests.\n\n\u003cdiv align=\"center\" style=\"display:flex;flex-direction:column;\"\u003e\n\u003cbr/\u003e\n\n[![Internet Computer portal](https://img.shields.io/badge/Internet-Computer-grey?logo=internet%20computer)](https://internetcomputer.org)\n[![GitHub CI Checks Workflow Status](https://img.shields.io/github/actions/workflow/status/dfinity/internet-identity-playwright/checks.yml?logo=github\u0026label=CI%20checks)](https://github.com/dfinity/internet-identity-playwright/actions/workflows/checks.yml)\n[![GitHub CI Tests Workflow Status](https://img.shields.io/github/actions/workflow/status/dfinity/internet-identity-playwright/tests.yml?logo=github\u0026label=CI%20tests)](https://github.com/dfinity/internet-identity-playwright/actions/workflows/tests.yml)\n\n\u003c/div\u003e\n\n## 🚀 Introduction\n\nThis repository offers Playwright fixtures designed to assist developers in creating end-to-end (E2E) tests for dApps utilizing Internet Identity. These pre-built scenarios allow developers to seamlessly integrate authentication flows, including the creation and reuse of identities, without needing to implement the flows themselves.\n\n## 🖥️ Installation\n\n```bash\n# with npm\nnpm install --save-dev @dfinity/internet-identity-playwright\n# with pnpm\npnpm add --save-dev @dfinity/internet-identity-playwright\n# with yarn\nyarn add -D @dfinity/internet-identity-playwright\n```\n\n## ✍️ Usage\n\nTo use the Internet Identity Playwright fixtures, follow these steps:\n\n### 1. Import the Fixtures\n\nIn your Playwright test file, import the fixtures provided by this library.\n\n```javascript\nimport {testWithII} from '@dfinity/internet-identity-playwright';\n```\n\n### 2. Write Your Tests\n\nUse the extended fixtures in your tests to perform authentication flows.\n\n\u003e [!NOTE]\n\u003e The `signIn()` method automatically detects whether this is a first-time passkey flow or an existing passkey flow, handling the complexity for you.\n\u003e It is also worth noting that it always tries to reuse the same default identity that was created within a Playwright session to ensure the provided identity is reproducible.\n\n```javascript\ntestWithII('should sign-in with a user', async ({page, iiPage}) =\u003e {\n  await page.goto('/');\n\n  await iiPage.signIn();\n});\n```\n\nThe `iiPage` object represents the page of your application that contains the call to action to start the authentication flow with Internet Identity.\n\nBy default, the fixture will search for a button identified by the attribute `[data-tid=login-button]`. You can customize this behavior by providing your own selector.\n\n```javascript\nconst loginSelector = '#login';\n\ntestWithII('should sign-in with a user', async ({page, iiPage}) =\u003e {\n  await page.goto('/');\n\n  await iiPage.signIn({passkey: {selector: loginSelector}});\n});\n```\n\nWhen creating a new passkey for the first time, the identity name is set by default to \"Test\". You can customize this behavior or create other accounts with the parameter `account`.\n\n\u003e [!NOTE]\n\u003e Creating an account requires having signed in a first time within a Playwright session.\n\n```javascript\nconst loginSelector = '#login';\n\ntestWithII('should sign-in with a user', async ({page, iiPage}) =\u003e {\n  await page.goto('/');\n\n  await iiPage.signIn();\n\n  await page.locator('#logout').click();\n\n  await iiPage.signIn({passkey: {account: 'Hello World'}});\n});\n```\n\n### 3. Wait for Internet Identity (optional)\n\nYou might encounter scenarios where you perform tests against a local replica started in parallel with your tests, commonly when automating the tests in a CI environment. The library also exposes a fixture that lets you wait for Internet Identity to be ready.\n\nFor example, you can provide the local replica URL and the canister ID on which Internet Identity has been deployed:\n\n```javascript\ntestWithII.beforeEach(async ({iiPage, browser}) =\u003e {\n  const url = 'http://127.0.0.1:4943';\n  const canisterId = 'rdmx6-jaaaa-aaaaa-aaadq-cai';\n\n  await iiPage.waitReady({url, canisterId});\n});\n```\n\nThe function also accepts an optional timeout parameter to specify how long the function should wait for Internet Identity to be mounted, with a default value of 60000 milliseconds.\n\n```javascript\ntestWithII.beforeEach(async ({iiPage, browser}) =\u003e {\n  const url = 'http://127.0.0.1:4943';\n  const canisterId = 'rdmx6-jaaaa-aaaaa-aaadq-cai';\n  const timeout = 30000;\n\n  await iiPage.waitReady({url, canisterId, timeout});\n});\n```\n\n### 4. Run Your Tests\n\nRun your Playwright tests as usual.\n\n```bash\nnpx playwright test\n```\n\n## 💁‍♂️️ Tips \u0026 tricks\n\n### Example Test\n\nYou can find an example test in the following file: [login.spec.ts](./e2e/login.spec.ts).\n\n### Running Tests Locally\n\nTo run these tests locally, follow the steps below:\n\n1. Install a container runtime:\n\nMake sure you have an up-to-date container runtime installed on your machine, such as [Docker](https://www.docker.com/) or [Podman](https://podman.io/).\n\nThe suite uses Docker by default. If you're using Podman instead, update the emulator config in [demo/juno.config.mjs](./demo/juno.config.mjs):\n\n```\nemulator: {\n  runner: {\n    type: \"podman\"\n  },\n  satellite: {}\n}\n```\n\n2. Install Juno's CLI:\n\n```\nnpm i -g @junobuild/cli\n```\n\n3. Start the emulator:\n\nNavigate to the [demo](./demo) directory and start the environment:\n\n```bash\ncd demo\njuno emulator start\n```\n\n4. Setup the environment:\n\nIf this is the first time you're running the tests locally, you need to configure the backend of the demo application by authorizing your CLI to operate the demo's Satellite (canister) and applying its backend configuration:\n\n```bash\njuno login --emulator --mode development\njuno config apply --mode development\n```\n\n5. Run the Tests:\n\nReturn to the root directory and execute the tests:\n\n```bash\nnpm run e2e\n```\n\n### Running Captcha Tests Locally\n\nThe default test suite validates the use of Internet Identity without captcha requirements. To test a flow with captcha, run the following command in the `demo` directory:\n\n```bash\ndocker compose -f docker-compose.captcha.yml up\n```\n\nThen, navigate to the root directory and run the dedicated test:\n\n```bash\nnpm run e2e:captcha\n```\n\n### Running Required Passkey Tests Locally\n\nThe default test suite validates the use of the latest Internet Identity, which does not require the user to complete a specific step to create a passkey. To test a flow where passkey creation is required, run the following command from the `demo` directory:\n\n```bash\ndocker compose -f docker-compose.passkey.yml up\n```\n\nThen, navigate to the root directory and run the dedicated test:\n\n```bash\nnpm run e2e:passkey\n```\n\n## 🚧 Limitations\n\nCurrently, the library's fixtures cannot be implemented with Playwright's ability to [load existing authenticated state](https://playwright.dev/docs/auth). Playwright currently does not support IndexedDB for such features. This limitation is tracked in their [GitHub issue #11164](https://github.com/microsoft/playwright/issues/11164).\n\nWhile it is technically possible to use local storage instead of IndexedDB, this approach is generally discouraged as it does not reflect how identities are stored in the browser. We prefer to adhere to best practices for testing to ensure the most accurate simulation of real-world scenarios.\n\n## 🧑‍🤝‍🧑 Community\n\n- [Forum](https://forum.dfinity.org/)\n- [Discord](https://discord.internetcomputer.org)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfinity%2Finternet-identity-playwright","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdfinity%2Finternet-identity-playwright","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfinity%2Finternet-identity-playwright/lists"}