How to fix Playwright Test error: "did not expect test() to be called here"?

Playwright

This occurs when test() is invoked outside a test file context, often in config/helpers imported by config.

Keep test() calls only in spec files and move shared logic to plain functions.

// helpers/auth.ts
export async function login(page) {
  await page.goto('/login');
  await page.getByLabel('Email').fill('[email protected]');
}

Then call helper functions from *.spec.ts, not from playwright.config.ts.