How to fix Playwright geolocation/permissions not applying in tests?

Playwright

Location APIs fail when permission is not granted for the right origin or context.

Set geolocation and permissions at context/project level before page actions.

test.use({
  geolocation: { latitude: 37.7749, longitude: -122.4194 },
  permissions: ['geolocation'],
});

Common mistake: granting permissions after page.goto, which is often too late.