(browser, state)
| 46 | } |
| 47 | |
| 48 | async function runSmoke(browser, state) { |
| 49 | while (state.index < state.files.length) { |
| 50 | const file = state.files[state.index]; |
| 51 | state.index += 1; |
| 52 | |
| 53 | const errors = []; |
| 54 | const page = await browser.newPage(); |
| 55 | await page.setViewport({ width: 1280, height: 900 }); |
| 56 | page.on("pageerror", (e) => errors.push("pageerror: " + e.message)); |
| 57 | page.on("console", (msg) => { |
| 58 | if (msg.type() === "error") { |
| 59 | errors.push("console.error: " + msg.text()); |
| 60 | } |
| 61 | }); |
| 62 | try { |
| 63 | await page.goto("http://127.0.0.1:9200/samples/" + relSample(file), { waitUntil: "networkidle2", timeout: 30000 }); |
| 64 | await new Promise(r => setTimeout(r, 250)); |
| 65 | } catch (e) { |
| 66 | errors.push("navigation: " + e.message); |
| 67 | } |
| 68 | await page.close(); |
| 69 | |
| 70 | if (errors.length) { |
| 71 | state.status = false; |
| 72 | state.failed.push(file); |
| 73 | console.log(chalk.red("[smoke] " + relSample(file))); |
| 74 | errors.forEach(e => console.log(chalk.red(" " + e))); |
| 75 | } else { |
| 76 | console.log("[smoke] " + relSample(file)); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | async function main() { |
| 82 | const start = new Date(); |
no test coverage detected