Don't use expect within Promises (#5466) (#5473)

* Don't use expect within Promises (#5466)

If a call to expect fails within a Promise it will not
be resolved, and causing the test to crash.

The patch aligns the code similar to what is used by all
the other tests.
This commit is contained in:
Henrik Skupin 2020-05-26 10:22:11 +02:00 committed by GitHub
parent dfb2e6056b
commit 6cfe142af1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14990 additions and 14977 deletions

29941
src/protocol.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@ -25,16 +25,22 @@ const {
describe('Page.Events.Dialog', function () {
setupTestBrowserHooks();
setupTestPageAndContextHooks();
it('should fire', async () => {
const { page } = getTestState();
page.on('dialog', (dialog) => {
expect(dialog.type()).toBe('alert');
expect(dialog.defaultValue()).toBe('');
expect(dialog.message()).toBe('yo');
const onDialog = sinon.stub().callsFake((dialog) => {
dialog.accept();
});
page.on('dialog', onDialog);
await page.evaluate(() => alert('yo'));
expect(onDialog.callCount).toEqual(1);
const dialog = onDialog.firstCall.args[0];
expect(dialog.type()).toBe('alert');
expect(dialog.defaultValue()).toBe('');
expect(dialog.message()).toBe('yo');
});
itFailsFirefox('should allow accepting prompts', async () => {

View File

@ -163,15 +163,21 @@ describe('navigation', function () {
// Make sure that network events do not emit 'undefined'.
// @see https://crbug.com/750469
page.on('request', (request) => expect(request).toBeTruthy());
page.on('requestfinished', (request) => expect(request).toBeTruthy());
page.on('requestfailed', (request) => expect(request).toBeTruthy());
const requests = [];
page.on('request', (request) => requests.push('request'));
page.on('requestfinished', (request) => requests.push('requestfinished'));
page.on('requestfailed', (request) => requests.push('requestfailed'));
let error = null;
await page
.goto(httpsServer.EMPTY_PAGE)
.catch((error_) => (error = error_));
if (isChrome) expect(error.message).toContain(EXPECTED_SSL_CERT_MESSAGE);
else expect(error.message).toContain('SSL_ERROR_UNKNOWN');
expect(requests.length).toBe(2);
expect(requests[0]).toBe('request');
expect(requests[1]).toBe('requestfailed');
});
itFailsFirefox(
'should fail when navigating to bad SSL after redirects',