in src/push/run-local.ts [129:155]
export async function runLocal(schemas: MonitorSchema[]) {
// lookup installed bin path of a node module
const resolvedPath = execFileSync('which', ['elastic-synthetics'], {
encoding: 'utf8',
}).trim();
const synthPath = resolvedPath.replace(
join('bin', 'elastic-synthetics'),
join('lib', 'node_modules', '@elastic/synthetics')
);
const rand = Date.now();
const zipPath = join(tmpdir(), `synthetics-zip-${rand}.zip`);
const unzipPath = join(tmpdir(), `synthetics-unzip-${rand}`);
try {
for (const schema of schemas) {
await extract(schema, zipPath, unzipPath);
}
await writePkgJSON(unzipPath, synthPath);
await runNpmInstall(unzipPath);
// TODO: figure out a way to collect all params and Playwright options
await runTest(unzipPath, schemas[0]);
} catch (e) {
throw red(`Aborted: ${e.message}`);
} finally {
await rm(zipPath, { recursive: true, force: true });
await rm(unzipPath, { recursive: true, force: true });
}
}