I’m using playwright for e2e and I have such code to fill in email/pwd and get redirected after successful login:
const {expect, test} = require('@playwright/test');
const {
signUrl,
testUser,
homeUrl,
} = require('../data/const');
test.describe('E2E Social', () => {
test.beforeEach(async ({page}, testInfo) => {
console.log(`Running ${testInfo.title}`);
});
test.describe('sign in page', () => {
test('can sign in', async ({ page, context }) => {
await page.goto(signUrl);
await page.locator('input[type="email"]').first().fill(testUser.login);
await page
.locator('input[type="password"]')
.first()
.fill(testUser.pwd);
const submitButton = page.locator('input[type="submit"]');
await expect(submitButton).toBeVisible();
await expect(submitButton).toHaveText('Log in');
const [loginPage] = await Promise.all([
context.waitForEvent('page'),
submitButton.click(),
]);
await loginPage.waitForLoadState();
await loginPage.bringToFront();
await loginPage.waitForTimeout(5000);
await expect(loginPage.url()).toBe(homeUrl);
});
});
});
but for whatever reasons I see that it goes to the new page (screenshots), but… after 30sec test is canceled with
waitForEvent('page') Test timeout of 30000ms exceeded.
What I do wrong?