test: convert a few more specs to async/await (#39712)

This commit is contained in:
Milan Burda 2023-09-04 12:33:29 +02:00 committed by GitHub
parent 54d8402a6c
commit f27b034045
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 70 additions and 89 deletions

View file

@ -13,6 +13,7 @@ import { ifit, ifdescribe, defer, itremote, listen } from './lib/spec-helpers';
import { PipeTransport } from './pipe-transport';
import * as ws from 'ws';
import { setTimeout } from 'node:timers/promises';
import { AddressInfo } from 'node:net';
const features = process._linkedBinding('electron_common_features');
@ -56,12 +57,12 @@ describe('reporting api', () => {
res.end('<script>window.navigator.vibrate(1)</script>');
});
await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve));
await listen(server);
const bw = new BrowserWindow({ show: false });
try {
const reportGenerated = once(reporting, 'report');
await bw.loadURL(`https://localhost:${(server.address() as any).port}/a`);
await bw.loadURL(`https://localhost:${(server.address() as AddressInfo).port}/a`);
const [reports] = await reportGenerated;
expect(reports).to.be.an('array').with.lengthOf(1);