MCPcopy
hub / github.com/realworld-apps/realworld / register

Function register

specs/e2e/helpers/auth.ts:3–23  ·  view source on GitHub ↗
(page: Page, username: string, email: string, password: string)

Source from the content-addressed store, hash-verified

1import { Page } from '@playwright/test';
2
3export async function register(page: Page, username: string, email: string, password: string) {
4 await page.goto('/register', { waitUntil: 'load' });
5 await page.fill('input[name="username"]', username);
6 await page.fill('input[name="email"]', email);
7 await page.fill('input[name="password"]', password);
8
9 // Wait for navigation to complete or error to appear
10 try {
11 await Promise.all([page.waitForURL('/'), page.click('button[type="submit"]')]);
12 } catch (error) {
13 // If navigation fails, check for errors
14 const errorMsg = await page
15 .locator('.error-messages')
16 .textContent()
17 .catch(() => '');
18 if (errorMsg) {
19 throw new Error(`Registration failed: ${errorMsg}`);
20 }
21 throw error;
22 }
23}
24
25export async function login(page: Page, email: string, password: string) {
26 await page.goto('/login', { waitUntil: 'load' });

Callers 9

auth.spec.tsFile · 0.90
social.spec.tsFile · 0.90
comments.spec.tsFile · 0.90
navigation.spec.tsFile · 0.90
articles.spec.tsFile · 0.90
settings.spec.tsFile · 0.90
createUserInIsolationFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected