tests: fix race condition in codegen tests (#26405)

The console message comes in once the page navigates, not in the
`page.setContent()` call below.
This commit is contained in:
Andrey Lushnikov 2023-08-10 07:51:38 -07:00 committed by GitHub
parent 167165d179
commit 0bb4dac28f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -109,7 +109,6 @@ class Recorder {
async setPageContentAndWait(page: Page, content: string, url: string = 'about:blank', frameCount: number = 1) {
let callback;
const result = new Promise(f => callback = f);
await page.goto(url);
let msgCount = 0;
const listener = msg => {
if (msg.text() === 'Recorder script ready for test') {
@ -121,6 +120,7 @@ class Recorder {
}
};
page.on('console', listener);
await page.goto(url);
await Promise.all([
result,
page.setContent(content)
@ -236,4 +236,4 @@ class CLIMock {
text() {
return stripAnsi(this.process.output);
}
}
}