Best JavaScript code snippet using stryker-parent
3-dry-run-executor.ts
Source:3-dry-run-executor.ts
...98 throw new ConfigError('There were failed tests in the initial test run.');99 }100 return;101 case DryRunStatus.Error:102 this.logErrorsInInitialRun(runResult);103 break;104 case DryRunStatus.Timeout:105 this.logTimeoutInitialRun();106 break;107 }108 throw new Error('Something went wrong in the initial test run');109 }110 private async timeDryRun(testRunner: TestRunner): Promise<{ dryRunResult: CompleteDryRunResult; timing: Timing }> {111 const dryRunTimeout = this.options.dryRunTimeoutMinutes * 1000 * 60;112 this.timer.mark(INITIAL_TEST_RUN_MARKER);113 this.log.info(114 `Starting initial test run (${this.options.testRunner} test runner with "${this.options.coverageAnalysis}" coverage analysis). This may take a while.`115 );116 this.log.debug(`Using timeout of ${dryRunTimeout} ms.`);117 const dryRunResult = await testRunner.dryRun({118 timeout: dryRunTimeout,119 coverageAnalysis: this.options.coverageAnalysis,120 disableBail: this.options.disableBail,121 });122 const grossTimeMS = this.timer.elapsedMs(INITIAL_TEST_RUN_MARKER);123 const humanReadableTimeElapsed = this.timer.humanReadableElapsed(INITIAL_TEST_RUN_MARKER);124 this.validateResultCompleted(dryRunResult);125 this.remapSandboxFilesToOriginalFiles(dryRunResult);126 const timing = this.calculateTiming(grossTimeMS, humanReadableTimeElapsed, dryRunResult.tests);127 return { dryRunResult, timing };128 }129 /**130 * Remaps test files to their respective original names outside the sandbox.131 * @param dryRunResult the completed result132 */133 private remapSandboxFilesToOriginalFiles(dryRunResult: CompleteDryRunResult) {134 const disableTypeCheckingFileMatcher = new FileMatcher(this.options.disableTypeChecks);135 dryRunResult.tests.forEach((test) => {136 if (test.fileName) {137 test.fileName = this.sandbox.originalFileFor(test.fileName);138 // HACK line numbers of the tests can be offset by 1 because the disable type checks preprocessor could have added a `// @ts-nocheck` line.139 // We correct for that here if needed140 // If we do more complex stuff in sandbox preprocessing in the future, we might want to add a robust remapping logic141 if (test.startPosition && disableTypeCheckingFileMatcher.matches(test.fileName)) {142 test.startPosition.line--;143 }144 }145 });146 }147 private logInitialTestRunSucceeded(tests: TestResult[], timing: Timing) {148 this.log.info(149 'Initial test run succeeded. Ran %s tests in %s (net %s ms, overhead %s ms).',150 tests.length,151 timing.humanReadableTimeElapsed,152 timing.net,153 timing.overhead154 );155 }156 /**157 * Calculates the timing variables for the test run.158 * grossTime = NetTime + overheadTime159 *160 * The overhead time is used to calculate exact timeout values during mutation testing.161 * See timeoutMS setting in README for more information on this calculation162 */163 private calculateTiming(grossTimeMS: number, humanReadableTimeElapsed: string, tests: readonly TestResult[]): Timing {164 const netTimeMS = tests.reduce((total, test) => total + test.timeSpentMs, 0);165 const overheadTimeMS = grossTimeMS - netTimeMS;166 return {167 net: netTimeMS,168 overhead: overheadTimeMS < 0 ? 0 : overheadTimeMS,169 humanReadableTimeElapsed,170 };171 }172 private logFailedTestsInInitialRun(failedTests: FailedTestResult[]): void {173 let message = 'One or more tests failed in the initial test run:';174 failedTests.forEach((test) => {175 message += `${EOL}\t${test.name}`;176 message += `${EOL}\t\t${test.failureMessage}`;177 });178 this.log.error(message);179 }180 private logErrorsInInitialRun(runResult: ErrorDryRunResult) {181 const message = `One or more tests resulted in an error:${EOL}\t${runResult.errorMessage}`;182 this.log.error(message);183 }184 private logTimeoutInitialRun() {185 this.log.error('Initial test run timed out!');186 }...
Using AI Code Generation
1const { logErrorsInInitialRun } = require('stryker-parent');2logErrorsInInitialRun();3const { logErrorsInInitialRun } = require('stryker-parent');4logErrorsInInitialRun();5const { logErrorsInInitialRun } = require('stryker-parent');6logErrorsInInitialRun();7const { logErrorsInInitialRun } = require('stryker-parent');8logErrorsInInitialRun();9const { logErrorsInInitialRun } = require('stryker-parent');10logErrorsInInitialRun();11const { logErrorsInInitialRun } = require('stryker-parent');12logErrorsInInitialRun();13const { logErrorsInInitialRun } = require('stryker-parent');14logErrorsInInitialRun();15const { logErrorsInInitialRun } = require('stryker-parent');16logErrorsInInitialRun();17const { logErrorsInInitialRun } = require('stryker-parent');18logErrorsInInitialRun();19const { logErrorsInInitialRun } = require('stryker-parent');20logErrorsInInitialRun();21const { logErrorsInInitialRun } = require('stryker-parent');22logErrorsInInitialRun();23const { logErrorsInInitialRun } = require('stryker-parent');24logErrorsInInitialRun();25const { logErrorsInInitialRun } = require('stryker-parent');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!