(config: Config)
| 37 | ///////////////////////////////// |
| 38 | |
| 39 | async function main(config: Config) { |
| 40 | const hostUrl = `http://localhost:${config.angularCliPort}`; |
| 41 | const timeoutAttempts = config.timeout; |
| 42 | browser = await puppeteer.launch({ |
| 43 | headless: 'new', |
| 44 | handleSIGINT: false, |
| 45 | args: CHROME_ARGS, |
| 46 | }); |
| 47 | |
| 48 | await waitForNgServe(browser, hostUrl, timeoutAttempts); |
| 49 | |
| 50 | const scenarios = getSandboxMetadata(config, hostUrl, config.randomScenario); |
| 51 | console.log(`Retrieved ${scenarios.length} scenarios.\n`); |
| 52 | |
| 53 | reporter = new ErrorReporter(scenarios, config.reportPath, config.reportType); |
| 54 | const page = await setupPageAndErrorHandling(hostUrl); |
| 55 | for (let i = 0; i < scenarios.length; i++) { |
| 56 | console.log(`Checking [${i + 1}/${scenarios.length}]: ${scenarios[i].name}: ${scenarios[i].description}`); |
| 57 | await openScenario(scenarios[i], page); |
| 58 | } |
| 59 | await page.close(); |
| 60 | await browser.close(); |
| 61 | |
| 62 | const hasErrors = reporter.errors.length > 0; |
| 63 | // always generate report if report type is a file, or if there are errors |
| 64 | if (hasErrors || config.reportType !== REPORT_TYPE.LOG) { |
| 65 | reporter.compileReport(); |
| 66 | } |
| 67 | const exitCode = hasErrors ? 1 : 0; |
| 68 | process.exit(exitCode); |
| 69 | } |
| 70 | |
| 71 | async function setupPageAndErrorHandling(hostUrl): Promise<Page> { |
| 72 | const page = await browser.newPage(); |
no test coverage detected