Skip to content

Commit

Permalink
added puppeteer args
Browse files Browse the repository at this point in the history
  • Loading branch information
sr258 committed Dec 4, 2019
1 parent 943b035 commit c63f697
Showing 1 changed file with 66 additions and 56 deletions.
122 changes: 66 additions & 56 deletions test/e2e/H5PPlayer.DisplayContent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,65 +69,75 @@ fs.readdir(contentPath, (fsError, files) => {
server.listen(8080, () => {
// tslint:disable-next-line: no-console
console.log(`server running on http://localhost: ${8080}`);
puppeteer.launch({ devtools: true }).then(browser => {
fs.readdir(
extractedContentPath,
(fsExtractedError, extractedFiles) => {
extractedFiles.forEach((file, index) => {
queue
.add(
() =>
new Promise((resolve, reject) => {
browser.newPage().then(page => {
page.on('pageerror', msg => {
// tslint:disable-next-line: no-console
console.log(
`${file}: ERROR`,
msg
puppeteer
.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
devtools: true
})
.then(browser => {
fs.readdir(
extractedContentPath,
(fsExtractedError, extractedFiles) => {
extractedFiles.forEach((file, index) => {
queue
.add(
() =>
new Promise((resolve, reject) => {
browser.newPage().then(page => {
page.on(
'pageerror',
msg => {
// tslint:disable-next-line: no-console
console.log(
`${file}: ERROR`,
msg
);
process.exit(1);
reject(
new Error(
JSON.stringify(
file
)
)
);
}
);
process.exit(1);
reject(
new Error(
JSON.stringify(file)
)
);
});
page.goto(
`http://localhost:8080/examples/${file}`,
{
waitUntil:
'networkidle0'
}
).then(() => {
setTimeout(() => {
page.close();
// tslint:disable-next-line: no-console
console.log(
`${file}: OK`
);
resolve();
}, 1000);
page.goto(
`http://localhost:8080/examples/${file}`,
{
waitUntil:
'networkidle0'
}
).then(() => {
setTimeout(() => {
page.close();
// tslint:disable-next-line: no-console
console.log(
`${file}: OK`
);
resolve();
}, 1000);
});
});
});
})
)
.catch(error => {
// tslint:disable-next-line: no-console
console.log(error);
process.exit(1);
});
});
}
);
})
)
.catch(error => {
// tslint:disable-next-line: no-console
console.log(error);
process.exit(1);
});
});
}
);

const interval = setInterval(() => {
if (queue.getPendingLength() === 0) {
browser.close();
clearInterval(interval);
process.exit(0);
}
}, 500);
});
const interval = setInterval(() => {
if (queue.getPendingLength() === 0) {
browser.close();
clearInterval(interval);
process.exit(0);
}
}, 500);
});
});
});
});

0 comments on commit c63f697

Please sign in to comment.