mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Allow tests to be ignored by specific browsers
This commit is contained in:
@ -7,10 +7,16 @@ const slash = require('slash');
|
||||
const parseRefTest = require('./parse-reftest');
|
||||
const outputPath = 'tests/reftests.js';
|
||||
|
||||
const ignoredTests = [
|
||||
'/tests/reftests/background/radial-gradient.html',
|
||||
'/tests/reftests/text/chinese.html'
|
||||
];
|
||||
const ignoredTests = fs
|
||||
.readFileSync(path.resolve(__dirname, `../tests/reftests/ignore.txt`))
|
||||
.toString()
|
||||
.split('\n')
|
||||
.filter(l => l.length)
|
||||
.reduce((acc, l) => {
|
||||
const m = l.match(/^(\[(.+)\])?(.+)$/i);
|
||||
acc[m[3]] = m[2] ? m[2].split(',') : [];
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
glob(
|
||||
'../tests/reftests/**/*.html',
|
||||
@ -27,8 +33,7 @@ glob(
|
||||
const testList = files.reduce((acc, filename) => {
|
||||
const refTestFilename = path.resolve(__dirname, filename.replace(/\.html$/, '.txt'));
|
||||
const name = `/${slash(path.relative('../', filename))}`;
|
||||
if (ignoredTests.indexOf(name) === -1) {
|
||||
console.log(name);
|
||||
if (!Array.isArray(ignoredTests[name]) || ignoredTests[name].length) {
|
||||
acc[name] = fs.existsSync(refTestFilename)
|
||||
? parseRefTest(fs.readFileSync(refTestFilename).toString())
|
||||
: null;
|
||||
@ -36,12 +41,11 @@ glob(
|
||||
console.log(`IGNORED: ${name}`);
|
||||
}
|
||||
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname, `../${outputPath}`),
|
||||
`module.exports = ${JSON.stringify(testList, null, 4)};`
|
||||
`module.exports = ${JSON.stringify({testList, ignoredTests}, null, 4)};`
|
||||
);
|
||||
|
||||
console.log(`${outputPath} updated`);
|
||||
|
@ -10,7 +10,7 @@ app.use('/', express.static(path.resolve(__dirname, '../')));
|
||||
const listener = app.listen(0, () => {
|
||||
async function run() {
|
||||
const chromeless = new Chromeless();
|
||||
const tests = Object.keys(reftests);
|
||||
const tests = Object.keys(reftests.testList);
|
||||
let i = 0;
|
||||
while (tests[i]) {
|
||||
const filename = tests[i];
|
||||
|
Reference in New Issue
Block a user