🧪 Internet Identity Playwright Plugin

Who’s into End-to-End testing?

:point_right: Today, we are thrilled to open source today @dfinity/internet-identity-playwright - A Playwright library to simplify the integration of Internet Identity authentication in E2E tests. :rocket:


In June, I attended a workshop on E2E testing in the Web3 space at Blocksplit. The presenter demonstrated a Playwright plugin designed to facilitate test integration with Metamask. The demo was quite neat, and it sparked a discussion among my colleagues. We decided to replicate this approach for II, as we conduct E2E tests for the dApps we collaborate on and would probably be beneficial for anyone interested to easily set up tests with II, both locally and CI environments.



For more information, you can visit our repository but, here’s the brief summary (assuming you already have Playwright setup in your project):

  1. :desktop_computer: Installation
# with npm
npm install --save-dev @dfinity/internet-identity-playwright
# with pnpm
pnpm add --save-dev @dfinity/internet-identity-playwright
# with yarn
yarn add -D @dfinity/internet-identity-playwright
  1. :writing_hand: Usage

a. Import the Fixtures in Your Tests

import {testWithII} from '@dfinity/internet-identity-playwright';

b. Write Your Tests

testWithII('should sign-in with a new user', async ({page, iiPage}) => {
  await page.goto('/');

  await iiPage.signInWithNewIdentity();

Done. You have an E2E test that follows a sign-in workflow with II.

Let us know what you think, happying testing! :smiley: