MCPcopy Create free account
hub / github.com/SoCreate/angular-playground / main

Function main

projects/cli/src/check-snapshots.ts:55–83  ·  view source on GitHub ↗
(config: Config, hostUrl: string, testPath: string, viewportConfig?: ViewportOptions)

Source from the content-addressed store, hash-verified

53/////////////////////////////////
54
55async 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
85function normalizeResolvePath(directory) {
86 const absolutePath = isAbsolute(directory) ? directory : resolvePath('.', directory);

Callers 1

checkSnapshotsFunction · 0.70

Calls 4

waitForNgServeFunction · 0.90
writeSandboxesToTestFileFunction · 0.85
formatViewportSizeFunction · 0.85
clearOldTestFilesFunction · 0.85

Tested by

no test coverage detected