Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e test expect the page to have changed url but doesn't wait for it to change #645

Closed
fredericrous opened this issue Mar 10, 2024 · 2 comments

Comments

@fredericrous
Copy link
Contributor

fredericrous commented Mar 10, 2024

On my 2019 16" mac, the tests do not run fast enough.
I cannot expect the url to have changed after a test clicks a button.

For example, in onboarding.test.ts this code won't work:

await createAccountLink.click()
await expect(page).toHaveURL(`/signup`)

however this code does work:

  await createAccountLink.click()

  await page.waitForURL('/signup');

we can just replace toHaveURL with waitForURL. I mean the test should fail if waitForURL does not resolve, therefore no need to expect on top of waitForURL, right?
Final word, I'm not saying to replace all expect(page).toHaveURL with await page.waitForURL. The ones after await page.goto are fine

also the timeouts are too short. I need to set globaly at least timeout: 20 * 1000. and for the onboarding test reset password with a short code I need to set it to test.setTimeout(30 * 1000);

@kentcdodds
Copy link
Member

Interesting. I believe the assertion will wait just as long as the wait utility does. So maybe increasing the timeout is the right solution for you.

@fredericrous
Copy link
Contributor Author

good catch @kentcdodds indeed the timeout for expect is different. I only modified the timeout for tests.

This also made me realise my tests are taking longer due to how I configured i18next instantiation. I'll be closing the issue and will add my findings to rperon/epic-stack-with-i18n#8

thank you for the quick answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants