mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
5a5b4bb93c
* Replace Puppeteer by Playwright * Remove the limit of workers on ci * Various fixes after review * Document things
39 lines
799 B
TypeScript
39 lines
799 B
TypeScript
import psi from 'psi';
|
|
|
|
import { getContentTestURL, getTargetURL } from './utils';
|
|
|
|
interface Test {
|
|
url: string;
|
|
strategy: 'mobile' | 'desktop';
|
|
threshold: number;
|
|
}
|
|
|
|
const tests: Array<Test> = [
|
|
{
|
|
url: 'https://docs.gitbook.com',
|
|
strategy: 'desktop',
|
|
threshold: 90,
|
|
},
|
|
|
|
{
|
|
url: 'https://docs.gitbook.com',
|
|
strategy: 'mobile',
|
|
threshold: 80,
|
|
},
|
|
];
|
|
|
|
console.log(`Starting PageSpeed testing with ${getTargetURL()}...`);
|
|
|
|
for (const test of tests) {
|
|
const url = getContentTestURL(test.url);
|
|
|
|
console.log(`Testing ${url} on ${test.strategy}...`);
|
|
await psi.output(url, {
|
|
strategy: test.strategy,
|
|
threshold: test.threshold,
|
|
key: process.env.PAGESPEED_API_KEY,
|
|
});
|
|
|
|
console.log('');
|
|
}
|