Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
andrewyng avatar

Login Flows

  • 73 installs
  • 13.9k repo stars
  • Updated May 31, 2026
  • andrewyng/context-hub

login-flows is a Claude skill offering reusable Playwright patterns for automating username/password, OAuth/SSO, storageState reuse, and 2FA login in end-to-end tests.

About

A Claude skill with reusable Playwright patterns for automating login flows in end-to-end tests. It provides code for username/password login, OAuth/SSO redirects, persisting auth state with storageState, and TOTP-based 2FA handling. A developer uses it while writing Playwright E2E suites to authenticate test sessions reliably and avoid logging in before every test.

  • Reusable Playwright patterns for automating login in end-to-end tests
  • Covers username/password, OAuth/SSO, storageState reuse, and TOTP 2FA
  • Recommends storageState to avoid logging in before every test

Login Flows by the numbers

  • 73 all-time installs (skills.sh)
  • Ranked #1,083 of 2,155 Testing & QA skills by installs in the Skillselion catalog
  • Data as of Aug 3, 2026 (Skillselion catalog sync)
At a glance

login-flows capabilities & compatibility

Capabilities
testing
Works with
playwright
Use cases
testing
Pricing
Free
From the docs

What login-flows says it does

Reusable patterns for automating login flows in end-to-end tests.
SKILL.md
Always use `storageState` to avoid repeated logins — it's the single biggest speedup for E2E suites
SKILL.md
Use environment variables for credentials, never hardcode them
SKILL.md
npx skills add https://github.com/andrewyng/context-hub --skill login-flows

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs73
repo stars13.9k
Last updatedMay 31, 2026
Repositoryandrewyng/context-hub

What it does

Automate login (password, OAuth/SSO, 2FA) and persist auth state in Playwright end-to-end tests.

Who is it for?

Authenticating test sessions in Playwright E2E suites, including OAuth and TOTP-based 2FA.

Skip if: Automating logins against real users or systems, or hardcoding credentials in tests.

When should I use this skill?

Writing Playwright end-to-end tests that need username/password, OAuth/SSO, persisted auth, or 2FA login.

What you get

Reliable, reusable Playwright login helpers plus persisted storageState for fast E2E runs.

  • reusable login helper functions
  • global-setup storageState configuration

By the numbers

  • 4 login patterns (password, OAuth/SSO, storageState, MFA/2FA)

Files

SKILL.mdMarkdownGitHub ↗

Login Flow Patterns for Playwright

Reusable patterns for automating login flows in end-to-end tests.

Basic Username/Password Login

import { Page } from '@playwright/test';

async function login(page: Page, username: string, password: string) {
  await page.goto('/login');
  await page.fill('[name="username"]', username);
  await page.fill('[name="password"]', password);
  await page.click('button[type="submit"]');
  await page.waitForURL('/dashboard');
}

OAuth / SSO Login

For OAuth flows that redirect to an external provider:

async function loginWithOAuth(page: Page) {
  await page.goto('/login');
  await page.click('text=Sign in with Google');

  // Handle the OAuth popup or redirect
  await page.fill('input[type="email"]', process.env.TEST_EMAIL!);
  await page.click('text=Next');
  await page.fill('input[type="password"]', process.env.TEST_PASSWORD!);
  await page.click('text=Next');

  // Wait for redirect back to app
  await page.waitForURL('**/dashboard');
}

Persisting Auth State (storageState)

Avoid logging in before every test by saving and reusing browser state:

// global-setup.ts — runs once before all tests
import { chromium } from '@playwright/test';

async function globalSetup() {
  const browser = await chromium.launch();
  const page = await browser.newPage();

  await page.goto('/login');
  await page.fill('[name="username"]', 'testuser');
  await page.fill('[name="password"]', 'testpass');
  await page.click('button[type="submit"]');
  await page.waitForURL('/dashboard');

  // Save signed-in state
  await page.context().storageState({ path: './auth.json' });
  await browser.close();
}

export default globalSetup;

Then in playwright.config.ts:

export default defineConfig({
  globalSetup: './global-setup.ts',
  use: {
    storageState: './auth.json',
  },
});

MFA / 2FA Handling

For test environments with TOTP-based 2FA:

import { authenticator } from 'otplib';

async function loginWithMFA(page: Page, secret: string) {
  await login(page, 'user', 'pass');

  // Generate TOTP code
  const code = authenticator.generate(secret);
  await page.fill('[name="totp"]', code);
  await page.click('button[type="submit"]');
  await page.waitForURL('/dashboard');
}

Tips

  • Always use storageState to avoid repeated logins — it's the single biggest speedup for E2E suites
  • Use environment variables for credentials, never hardcode them
  • For CI, consider a dedicated test user with stable credentials
  • Use page.waitForURL() instead of arbitrary waitForTimeout() after login

Related skills

FAQ

How do I avoid logging in before every test?

Use storageState to save the signed-in browser state once in global setup and reuse it via the Playwright config's use.storageState.

Can it handle 2FA?

Yes, it generates TOTP codes with otplib and fills the 2FA field for test environments.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.