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

Fix external link checker exception handling #2147

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

Eric-Arellano
Copy link
Collaborator

We weren't properly catching errors due to reusing the symbol error. That resulted in a test recently saying that a link we expected to 404 was instead a valid link.

This PR also improves the tests to be deterministic by mocking fetch(). This removes the risk of flakiness and makes our test faster.

@@ -20,21 +20,38 @@ test("ExternalLink constructor ignores anchors", () => {
});

test.describe("ExternalLink.check()", () => {
let originalFetch: typeof global.fetch;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that this approach would not be safe if Playwright ran the tests inside a file in parallel. However, it runs them sequentially.

Copy link
Member

@frankharkins frankharkins left a comment

Choose a reason for hiding this comment

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

Thanks! Good idea to override for testing

@Eric-Arellano Eric-Arellano added this pull request to the merge queue Oct 17, 2024
Merged via the queue into main with commit cc1fd8d Oct 17, 2024
3 checks passed
@Eric-Arellano Eric-Arellano deleted the EA/fix-external-link-test branch October 17, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants