我有以下测试用例:
it('User can logout', async () => {
await helper.navClick('.header-user-action__logout');
const url = page.url();
console.log(url)
await expect(url).toContain('auth');
});
helper.navClick
只是一个小包装:
async function navClick(selector, options) {
return await Promise.all([page.waitForNavigation(), expect(page).toClick(selector, options)]);
}
大多数情况下,它会毫无问题地成功,但有时会被标记为失败:
✕ User can logout (569 ms)
● Login › User can logout
console.log
https://auth.example.com/auth/realms/example/protocol/openid-connect/auth?response_type=code&client_id=example-app&redirect_uri=https%3A%2F%2Fexample.com%2Fsso%2Flogin&state=807469fd-3ee5-4d93-8354-ca47a63e69a6&login=true&scope=openid
这怎么可能发生?该网址多次包含“auth”,我没有看到任何其他可能导致测试失败的内容。