(config: Config, hostUrl: string, testPath: string, viewportConfig?: ViewportOptions)
| 53 | ///////////////////////////////// |
| 54 | |
| 55 | async function main(config: Config, hostUrl: string, testPath: string, viewportConfig?: ViewportOptions) { |
| 56 | // create test file to run with jest |
| 57 | writeSandboxesToTestFile(config, hostUrl, testPath, viewportConfig); |
| 58 | |
| 59 | // launch puppeteer headless browser to render scenarios |
| 60 | browser = await puppeteer.launch({ |
| 61 | headless: true, |
| 62 | handleSIGINT: false, |
| 63 | args: CHROME_ARGS, |
| 64 | }); |
| 65 | |
| 66 | const timeoutAttempts = config.timeout; |
| 67 | await waitForNgServe(browser, hostUrl, timeoutAttempts); |
| 68 | const testRegex = viewportConfig |
| 69 | ? `test-image-snapshots-${formatViewportSize(viewportConfig)}\\.js$` |
| 70 | : 'test-image-snapshots\\.js'; |
| 71 | const argv = { |
| 72 | updateSnapshot: !!config.updateSnapshots, |
| 73 | testRegex |
| 74 | } as JestConfig.Argv; |
| 75 | const projectPath = resolvePath('.'); |
| 76 | const projects = [projectPath]; |
| 77 | const { results } = await runCLI(argv, projects); |
| 78 | |
| 79 | await browser.close(); |
| 80 | const exitCode = results.numFailedTests === 0 ? 0 : 1; |
| 81 | clearOldTestFiles(); |
| 82 | return exitCode; |
| 83 | } |
| 84 | |
| 85 | function normalizeResolvePath(directory) { |
| 86 | const absolutePath = isAbsolute(directory) ? directory : resolvePath('.', directory); |
no test coverage detected