Files
gitbook/tests/pagespeed-testing.ts
T
Samy Pessé 720c2ca909 Setup visual testing (#50)
* Add cloudflare job to publish pages

* Try like this

* Fix build path

* Try end to end

* Fix installation

* Use var instead of secret for CLOUDFLARE_PROJECT_NAME

* Use new puppeteer mode

* Add more tests

* Run in parallel

* Go back to no-concurrency

* Test pagespeed

* Print output

* Fix thresholds
2023-12-19 23:51:06 +01:00

38 lines
798 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('');
}