mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 08:36:33 +03:00
chore: update benchmark to latest puppeteer
This commit is contained in:
parent
d8d1cc174d
commit
4037e8492d
|
@ -9,6 +9,8 @@ const args = process.argv.slice(2);
|
||||||
args[0] = args[0] || 'HEAD';
|
args[0] = args[0] || 'HEAD';
|
||||||
args[1] = args[1] || 'local';
|
args[1] = args[1] || 'local';
|
||||||
|
|
||||||
|
let started = false;
|
||||||
|
|
||||||
console.log('Benchmarking revisions: ' + args.join(', '));
|
console.log('Benchmarking revisions: ' + args.join(', '));
|
||||||
|
|
||||||
const localDistDir = './benchmark/revisions/local/bundles';
|
const localDistDir = './benchmark/revisions/local/bundles';
|
||||||
|
@ -34,7 +36,7 @@ console.log('Starging benchmark server');
|
||||||
const proc = spawn('npm', ['run', 'start:benchmark']);
|
const proc = spawn('npm', ['run', 'start:benchmark']);
|
||||||
|
|
||||||
proc.stdout.on('data', data => {
|
proc.stdout.on('data', data => {
|
||||||
if (data.toString().indexOf('Project is running at') > -1) {
|
if (data.toString().indexOf('webpack: Compiled successfully') > -1) {
|
||||||
console.log('Server started');
|
console.log('Server started');
|
||||||
startBenchmark();
|
startBenchmark();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +59,9 @@ async function runPuppeteer() {
|
||||||
const prom = new Promise(_resolve => {
|
const prom = new Promise(_resolve => {
|
||||||
resolve = _resolve;
|
resolve = _resolve;
|
||||||
});
|
});
|
||||||
page.on('console', obj => {
|
page.on('console', async msg => {
|
||||||
|
const args = msg.args();
|
||||||
|
const obj = args.length > 0 && (await args[0].jsonValue());
|
||||||
if (!obj) return;
|
if (!obj) return;
|
||||||
|
|
||||||
if (obj.done) {
|
if (obj.done) {
|
||||||
|
@ -71,9 +75,7 @@ async function runPuppeteer() {
|
||||||
console.log(obj);
|
console.log(obj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await page.goto('http://localhost:9090', {
|
await page.goto('http://127.0.0.1:9090', { timeout: 0 });
|
||||||
waitUntil: 'networkidle',
|
|
||||||
});
|
|
||||||
const res = await prom;
|
const res = await prom;
|
||||||
await browser.close();
|
await browser.close();
|
||||||
return res;
|
return res;
|
||||||
|
@ -81,6 +83,8 @@ async function runPuppeteer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBenchmark() {
|
async function startBenchmark() {
|
||||||
|
if (started) return;
|
||||||
|
started = true;
|
||||||
console.log('Starting benchmarks');
|
console.log('Starting benchmarks');
|
||||||
await runPuppeteer();
|
await runPuppeteer();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user