Fix flaky test (#351)

The patch awaits the in-flight 'waitForElement'
This commit is contained in:
JoelEinbinder 2017-08-17 19:48:25 -07:00 committed by Andrey Lushnikov
parent 5f0afd5547
commit f3143a3d60

View File

@ -355,7 +355,7 @@ describe('Page', function() {
await page.goto(EMPTY_PAGE); await page.goto(EMPTY_PAGE);
let frame = page.mainFrame(); let frame = page.mainFrame();
let added = false; let added = false;
frame.waitForSelector('div').then(() => added = true); let watchdog = frame.waitForSelector('div').then(() => added = true);
// run nop function.. // run nop function..
await frame.evaluate(() => 42); await frame.evaluate(() => 42);
// .. to be sure that waitForSelector promise is not resolved yet. // .. to be sure that waitForSelector promise is not resolved yet.
@ -363,6 +363,7 @@ describe('Page', function() {
await frame.evaluate(addElement, 'br'); await frame.evaluate(addElement, 'br');
expect(added).toBe(false); expect(added).toBe(false);
await frame.evaluate(addElement, 'div'); await frame.evaluate(addElement, 'div');
await watchdog;
expect(added).toBe(true); expect(added).toBe(true);
})); }));