Skip to content

Conversation

@elliott-with-the-longest-name-on-github
Copy link
Contributor

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github commented Dec 23, 2025

please god fix my tests

edit: he has indeed

So after a full day of infuriation:

  • For some reason, the combination of Node 24 and Playwright 1.51.0 causes tests to randomly hang. I couldn't find an isolated Node version.
  • I still have not determined what caused this to start happening. As far as I can tell, nothing of note changed.
  • Unfortunately, upgrading to the latest Playwright does not work. 1.57.0 comes with chromium release 1200, which randomly segfaults... a lot
  • Upgrading to 1.56.0 fixes the issue, but... Playwright got faster and exposed some flaky tests. Those are now fixed.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot
Copy link

changeset-bot bot commented Dec 23, 2025

⚠️ No Changeset found

Latest commit: 54e9645

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

await page.goto('/routing/hashes/a');

await clicknav('[href="#hash-target"]');
expect(page.url()).toBe(`${baseURL}/routing/hashes/a#hash-target`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you should have to change these lines because clicknav does a waitForNavigation. If that's not working it's probably better to fix it inside clicknav so that there's a only a single location that needs to be updated

await Promise.all([page.waitForNavigation(options), element.click()]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think even if we updated clicknav it would still have to be updated to accept the "expected URL" as the second parameter. waitForNavigation probably won't ever be reliable (see microsoft/playwright#20853).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, interesting! It's so dumb that they have an API that is discouraged and not deprecated at the same time 😝

Doing something along the lines of microsoft/playwright#20853 (comment) would make a lot of sense. We already do something similar with body.started:

await page.waitForSelector('body.started', { timeout: 15000 });

Perhaps we could change from a boolean body.started to a timestamp body.lastNav or something along those lines. It'd keep the API on the caller's side much simpler

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that'll work as it won't actually work for clientside navs (it relies on window being destroyed and recreated during the nav). That being said maybe it could wait on afterNavigation or something?

For now I'm adding waitForURL as an option to it, which will make it significantly more reliable in the case where you're going clicknav(/* I want to go to a location, and wait until I've arrived at that location */)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it looks like we probably have access to afterNavigate:

afterNavigate: () => page.evaluate(() => afterNavigate(() => {})),

I'd really much prefer a solution using that as I think it'd be much easier to author tests that way. It's also something that I imagine could then be followed as a pattern in end user apps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually think it'll work, unfortunately -- it has to be linked to a component lifecycle ☹️

@svelte-docs-bot
Copy link

Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending a full bank of green lights

@benmccann benmccann changed the title chore: Upgrade Playwright chore: upgrade Playwright Dec 24, 2025
await page.goto('/routing/hashes/a');

await clicknav('[href="#preload"]');
expect(page.url()).toBe(`${baseURL}/routing/hashes/a#preload`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure we should remove these expect lines. perhaps the current waitForURL implementation checks that, but I'd like to fix this up so that we don't use waitForURL and I'm afraid it'd be easy to miss that we're no longer expecting anything while making that change

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're asserting that we've arrived at a URL, waitForURL is superior to expect(page.url()).toBe(...). It throws a helpful message after the configured timeout if the URL is never arrived at, and the test fails. It's not an explicit expect, but with Playwright you don't always end up with one -- like in this case, we're just making sure the URL actually has been updated to what we expected it to be.

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github merged commit 134ce49 into main Dec 24, 2025
44 of 45 checks passed
@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github deleted the elliott/upgrade-playwright branch December 24, 2025 19:17
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

Successfully merging this pull request may close these issues.

4 participants