Skip to content
lighthouse
Menu

Login helper · @houses/lighthouse-login-helpers

loginWithCredentials

Fill and submit a username and password form before the audit (Credential login).

await loginWithCredentials(page, {
  loginUrl: 'http://localhost:3000/login',
  usernameSelector: '#email',
  passwordSelector: '#password',
  submitSelector: 'button[type=submit]',
  username: process.env.E2E_USER,
  password: process.env.E2E_PASSWORD,
  successSelector: '[data-testid=dashboard]',
});

Opens loginUrl, types the username and password into the given fields, submits, and waits for successSelector instead of a fixed navigation wait, so client-side redirects work.

Meant for local, dev and staging environments without CAPTCHA or Turnstile. For production behind those, use injectSessionCookies.