test: fix serviceWorker test flakiness (#2195)

This patch starts waiting on serviceWorker registration.
This commit is contained in:
Andrey Lushnikov 2018-03-14 17:55:12 -07:00 committed by GitHub
parent 625c7ebdda
commit 4b7fbf8ee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -1,4 +1,4 @@
<link rel="stylesheet" href="./style.css">
<script>
navigator.serviceWorker.register('sw.js');
window.registrationPromise = navigator.serviceWorker.register('sw.js');
</script>

View File

@ -2862,6 +2862,7 @@ describe('Page', function() {
// Load and re-load to make sure serviceworker is installed and running.
await page.goto(server.PREFIX + '/serviceworkers/fetch/sw.html', {waitUntil: 'networkidle2'});
await page.evaluate(async() => await window.registrationPromise);
await page.reload();
expect(responses.size).toBe(2);