Tone.js/test/html/testHTML.js

40 lines
996 B
JavaScript
Raw Normal View History

2018-08-26 23:43:28 +00:00
const puppeteer = require("puppeteer");
const { resolve } = require("path");
const fs = require("fs");
function runPage(path){
return new Promise(async (done, error) => {
2018-08-27 00:02:58 +00:00
const browser = await puppeteer.launch({ args : ["--no-sandbox"] });
2018-08-26 23:43:28 +00:00
const page = await browser.newPage();
page.on("pageerror", e => error(e));
await page.goto(`file://${path}`, { waitFor : "networkidle0" });
await browser.close();
done();
});
}
context("HTML Tests", () => {
it("can run multiple contexts at once", () => {
return runPage(resolve(__dirname, "multiple_instances.html"));
});
it("has the same transport after offline test", () => {
return runPage(resolve(__dirname, "same_transport.html"));
});
});
context("Examples", () => {
const exampleDir = resolve(__dirname, "../../examples/");
const files = fs.readdirSync(exampleDir).filter(f => f.endsWith(".html"));
files.forEach(f => {
it(`can run example ${f}`, () => {
return runPage(resolve(exampleDir, f));
});
});
});