-
Notifications
You must be signed in to change notification settings - Fork 69
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(puppeteer,playwright): Await page close at end of test #487
Conversation
Hey @jpveooys, Thank you for your contribution, we will review this today |
1 similar comment
Hey @jpveooys, Thank you for your contribution, we will review this today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Minor change with regards to the try block
packages/playwright/src/index.ts
Outdated
try { | ||
return await blankPage.evaluate(axeFinishRun, { | ||
partialResults, | ||
options | ||
}) | ||
.finally(() => { | ||
blankPage.close(); | ||
}); | ||
} finally { | ||
await blankPage.close(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to await the blankPage.close()
from within the finally block without the use of the try:
return await blankPage
.evaluate(axeFinishRun, {
partialResults,
options
})
.finally(async () => {
await blankPage.close();
});
try { | ||
return await blankPage.evaluate( | ||
axeFinishRun, | ||
partialResults as JSONArray, | ||
axeOptions as JSONObject | ||
) | ||
.finally(() => { | ||
blankPage.close(); | ||
}); | ||
); | ||
} finally { | ||
await blankPage.close(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
return await blankPage
.evaluate(
axeFinishRun,
partialResults as JSONArray,
axeOptions as JSONObject
)
.finally(async () => {
await blankPage.close();
});
This resolves an intermittent 'ProtocolError: Protocol error (Target.closeTarget): Target closed.' error at the end of a test suite run depending on the environment.
In the interest of correctness and to match puppeteer.
7b64e99
to
74dbcb5
Compare
Hi @Zidious I've amended that – though I'd point out the rest of code in those files is using try blocks rather then promise methods, so I'm not sure what the reluctance is here. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you for contribution @jpveooys!
|
Due to circleCI not performing the tests, we will need to cherry pick this PR to get it merged. |
Resolves #484
This awaits the page close to resolve the intermittent error at the end of a test suite run mentioned in the linked issue.
The error was observed for Puppeteer, but the same fix is applied here for Playwright in the interest of correctness and consistency.
I'm not aware of any easy way to test for the original error, but all existing tests should be passing.