How to use the @stryker-mutator/util.fsAsPromised.readdir function in @stryker-mutator/util

To help you get started, we’ve selected a few @stryker-mutator/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stryker-mutator / stryker / e2e / helpers.ts View on Github external
export async function readMutationTestResult(eventResultDirectory = path.resolve('reports', 'mutation', 'events')) {
  const allReportFiles = await fsAsPromised.readdir(eventResultDirectory);
  const mutationTestReportFile = allReportFiles.find(file => !!file.match(/.*onMutationTestReportReady.*/));
  expect(mutationTestReportFile).ok;
  const mutationTestReportContent = await fsAsPromised.readFile(path.resolve(eventResultDirectory, mutationTestReportFile || ''), 'utf8');
  const report = JSON.parse(mutationTestReportContent) as mutationTestReportSchema.MutationTestResult;
  const metricsResult = calculateMetrics(report.files);
  return metricsResult;
}