forked from niklasvh/html2canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-reftests.js
37 lines (33 loc) · 1.21 KB
/
create-reftests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const {Chromeless} = require('chromeless');
const path = require('path');
const fs = require('fs');
const express = require('express');
const reftests = require('../tests/reftests');
const app = express();
app.use('/', express.static(path.resolve(__dirname, '../')));
const listener = app.listen(0, () => {
async function run() {
const chromeless = new Chromeless();
const tests = Object.keys(reftests.testList);
let i = 0;
while (tests[i]) {
const filename = tests[i];
i++;
const reftest = await chromeless
.goto(`http://localhost:${listener.address().port}${filename}?reftest&run=false`)
.evaluate(() =>
html2canvas(document.documentElement, {
windowWidth: 800,
windowHeight: 600,
target: new RefTestRenderer()
})
);
fs.writeFileSync(
path.resolve(__dirname, `..${filename.replace(/\.html$/i, '.txt')}`),
reftest
);
}
await chromeless.end();
}
run().catch(console.error.bind(console)).then(() => process.exit(0));
});