-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
43 lines (40 loc) · 1.4 KB
/
main.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
38
39
40
41
42
43
const puppeteer = require("puppeteer");
const {join} = require("path");
const tests = [
{path:"cba-list.js", name: "Testing CBA List"},
{path:"cba-list-new.js", name: "Testing CBA List new"},
{path:"cba-table.js", name: "Testing CBA Table"},
{path:"drag-drop.js", name: "Testing drag and drop"},
{path:"cba-list-sorting.js", name: "Testing CBA List sorting"},
{path:"cba-tooltip.js", name: "Testing CBA Tooltip"},
{path:"cba-list-tooltip.js", name: "Testing CBA Tooltip inside cba-list"},
];
let browser;
let page;
function run()
{
for (const {path, name} of tests)
{
describe(name, () =>
{
const {pageSetup} = require(`./tests/${path}`);
before(async () =>
{
browser = await puppeteer.launch({headless: true, args: ["--allow-file-access-from-files"]});
page = await browser.newPage();
await page.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3419.0 Safari/537.36");
await page.goto("http://127.0.0.1:3001/puppeteer");
for (const script of pageSetup.js)
{
await page.addScriptTag({url: join("/", "js", script), type: "module"});
}
await page.evaluate((bodyHTML) => document.body.innerHTML = bodyHTML, pageSetup.body);
});
after(async () =>
{
await browser.close();
})
});
}
}
module.exports = {page: () => page, run};