E2e default login helper
Skill kjuhwa/skills-hub/skills/testing/e2e-default-login-helper
Self-correcting knowledge corpus for Claude Code — 9 stable shape clusters, bias-correction pipeline baked into contribution flow. 47 papers, 45 techniques, 1.1k skills.
npx -y skills add kjuhwa/skills-hub --skill e2e-default-login-helperAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Reusable Playwright loginAsDefault helper that authenticates via API (send-code + verify-code), injects the token into localStorage, and navigates to a workspace-scoped URL.
SKILL.md
2.6 KB, 507 tokens by cl100k_base, as published. Nobody here has run it
When to use
- Playwright E2E suite against a real backend + frontend in dev/staging.
- You have a stable test user and want to skip the browser login flow.
Steps
- Define constants for the default E2E user:
const DEFAULT_E2E_NAME = "E2E User"; const DEFAULT_E2E_EMAIL = "[email protected]"; const DEFAULT_E2E_WORKSPACE = "e2e-workspace"; - Helper that uses
TestApiClientfor the API calls, then injects the token into browser storage:export async function loginAsDefault(page: Page): Promise<string> { const api = new TestApiClient(); await api.login(DEFAULT_E2E_EMAIL, DEFAULT_E2E_NAME); const workspace = await api.ensureWorkspace("E2E Workspace", DEFAULT_E2E_WORKSPACE); const token = api.getToken(); await page.goto("/login"); // start from a safe URL await page.evaluate((t) => { localStorage.setItem("myapp_token", t); }, token); await page.goto(`/${workspace.slug}/issues`); await page.waitForURL("**/issues", { timeout: 10000 }); return workspace.slug; } - In test specs:
let api: TestApiClient; test.beforeEach(async ({ page }) => { api = await createTestApi(); await loginAsDefault(page); }); test.afterEach(() => api.cleanup());
Example
test("create and view an issue", async ({ page }) => {
const issue = await api.createIssue("Test Issue");
await page.goto(`/e2e-workspace/issues/${issue.id}`);
await expect(page.getByText("Test Issue")).toBeVisible();
});
Caveats
loginAsDefaultstarts withpage.goto("/login")before writing to localStorage. Without that,page.evaluatemay run onabout:blankwhere localStorage writes don't persist.- Tests that exercise the login flow itself shouldn't use this helper — they need to go through the UI. Name them
*-login.spec.tsand opt out. - If the storage key or token format changes, update the helper first; Playwright tests will surface the breakage fast but the fix is in one place.