How to use disableTypeCheckingFileMatcher method in stryker-parent

Best JavaScript code snippet using stryker-parent

3-dry-run-executor.ts

Source:3-dry-run-executor.ts Github

copy

Full Screen

1import { EOL } from 'os';2import { Injector } from 'typed-inject';3import { I } from '@stryker-mutator/util';4import { Logger } from '@stryker-mutator/api/logging';5import { commonTokens, tokens } from '@stryker-mutator/api/plugin';6import { StrykerOptions, Mutant } from '@stryker-mutator/api/core';7import {8 DryRunResult,9 TestRunner,10 DryRunStatus,11 CompleteDryRunResult,12 TestStatus,13 TestResult,14 FailedTestResult,15 ErrorDryRunResult,16} from '@stryker-mutator/api/test-runner';17import { lastValueFrom, of } from 'rxjs';18import { Checker } from '@stryker-mutator/api/check';19import { coreTokens } from '../di';20import { Sandbox } from '../sandbox/sandbox';21import { Timer } from '../utils/timer';22import { createTestRunnerFactory } from '../test-runner';23import { MutationTestReportHelper } from '../reporters/mutation-test-report-helper';24import { ConfigError } from '../errors';25import { findMutantTestCoverage } from '../mutants';26import { ConcurrencyTokenProvider, Pool, createTestRunnerPool } from '../concurrent';27import { FileMatcher } from '../config';28import { MutationTestContext } from './4-mutation-test-executor';29import { MutantInstrumenterContext } from './2-mutant-instrumenter-executor';30const INITIAL_TEST_RUN_MARKER = 'Initial test run';31export interface DryRunContext extends MutantInstrumenterContext {32 [coreTokens.sandbox]: I<Sandbox>;33 [coreTokens.mutants]: readonly Mutant[];34 [coreTokens.checkerPool]: I<Pool<Checker>>;35 [coreTokens.concurrencyTokenProvider]: I<ConcurrencyTokenProvider>;36}37/**38 * A small object that keeps the timing variables of a test run.39 */40interface Timing {41 /**42 * The time that the test runner was actually executing tests in milliseconds.43 */44 net: number;45 /**46 * the time that was spend not executing tests in milliseconds.47 * So the time it took to start the test runner and to report the result.48 */49 overhead: number;50 /**51 * The total time spent (net + overhead) in a human readable format52 */53 humanReadableTimeElapsed: string;54}55function isFailedTest(testResult: TestResult): testResult is FailedTestResult {56 return testResult.status === TestStatus.Failed;57}58export class DryRunExecutor {59 public static readonly inject = tokens(60 commonTokens.injector,61 commonTokens.logger,62 commonTokens.options,63 coreTokens.timer,64 coreTokens.concurrencyTokenProvider,65 coreTokens.sandbox66 );67 constructor(68 private readonly injector: Injector<DryRunContext>,69 private readonly log: Logger,70 private readonly options: StrykerOptions,71 private readonly timer: I<Timer>,72 private readonly concurrencyTokenProvider: I<ConcurrencyTokenProvider>,73 public readonly sandbox: I<Sandbox>74 ) {}75 public async execute(): Promise<Injector<MutationTestContext>> {76 const testRunnerInjector = this.injector77 .provideFactory(coreTokens.testRunnerFactory, createTestRunnerFactory)78 .provideValue(coreTokens.testRunnerConcurrencyTokens, this.concurrencyTokenProvider.testRunnerToken$)79 .provideFactory(coreTokens.testRunnerPool, createTestRunnerPool);80 const testRunnerPool = testRunnerInjector.resolve(coreTokens.testRunnerPool);81 const { dryRunResult, timing } = await lastValueFrom(testRunnerPool.schedule(of(0), (testRunner) => this.timeDryRun(testRunner)));82 this.logInitialTestRunSucceeded(dryRunResult.tests, timing);83 if (!dryRunResult.tests.length) {84 throw new ConfigError('No tests were executed. Stryker will exit prematurely. Please check your configuration.');85 }86 return testRunnerInjector87 .provideValue(coreTokens.timeOverheadMS, timing.overhead)88 .provideValue(coreTokens.dryRunResult, dryRunResult)89 .provideClass(coreTokens.mutationTestReportHelper, MutationTestReportHelper)90 .provideFactory(coreTokens.mutantsWithTestCoverage, findMutantTestCoverage);91 }92 private validateResultCompleted(runResult: DryRunResult): asserts runResult is CompleteDryRunResult {93 switch (runResult.status) {94 case DryRunStatus.Complete:95 const failedTests = runResult.tests.filter(isFailedTest);96 if (failedTests.length) {97 this.logFailedTestsInInitialRun(failedTests);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 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = function(strykerConfig) {2 strykerConfig.disableTypeCheckingFileMatcher();3 return strykerConfig;4};5module.exports = function(config) {6 config.set({7 disableTypeCheckingFileMatcher: () => {8 return ['**/test.js'];9 },10 jest: {11 }12 });13};14module.exports = {15 transform: {16 },17 testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',18};19{20 "scripts": {21 },22 "devDependencies": {23 },24 "dependencies": {25 }26}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { disableTypeCheckingFileMatcher } = require('stryker-parent');2const { disableTypeCheckingFileMatcher } = require('stryker-parent');3disableTypeCheckingFileMatcher();4const { disableTypeCheckingFileMatcher } = require('stryker-parent');5disableTypeCheckingFileMatcher();6const { disableTypeCheckingFileMatcher } = require('stryker-parent');7disableTypeCheckingFileMatcher();8const { disableTypeCheckingFileMatcher } = require('stryker-parent');9disableTypeCheckingFileMatcher();10const { disableTypeCheckingFileMatcher } = require('stryker-parent');11disableTypeCheckingFileMatcher();12const { disableTypeCheckingFileMatcher } = require('stryker-parent');13disableTypeCheckingFileMatcher();14const { disableTypeCheckingFileMatcher } = require('stryker-parent');15disableTypeCheckingFileMatcher();16const { disableTypeCheckingFileMatcher } = require('stryker-parent');17disableTypeCheckingFileMatcher();18const { disableTypeCheckingFileMatcher } = require('stryker-parent');19disableTypeCheckingFileMatcher();20const { disableTypeCheckingFileMatcher } = require('stryker-parent');21disableTypeCheckingFileMatcher();22const { disableTypeCheckingFileMatcher } = require('stryker-parent');23disableTypeCheckingFileMatcher();24const { disableTypeCheckingFileMatcher } = require('stryker-parent');25disableTypeCheckingFileMatcher();26const { disableTypeCheckingFileMatcher } = require('stryker-parent');27disableTypeCheckingFileMatcher();

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2strykerParent.disableTypeCheckingFileMatcher();3const strykerParent = require('stryker-parent');4strykerParent.disableTypeCheckingFileMatcher();5const strykerParent = require('stryker-parent');6strykerParent.disableTypeCheckingFileMatcher();7const strykerParent = require('stryker-parent');8strykerParent.disableTypeCheckingFileMatcher();9const strykerParent = require('stryker-parent');10strykerParent.disableTypeCheckingFileMatcher();11const strykerParent = require('stryker-parent');12strykerParent.disableTypeCheckingFileMatcher();13const strykerParent = require('stryker-parent');14strykerParent.disableTypeCheckingFileMatcher();15const strykerParent = require('stryker-parent');16strykerParent.disableTypeCheckingFileMatcher();17const strykerParent = require('stryker-parent');18strykerParent.disableTypeCheckingFileMatcher();19const strykerParent = require('stryker-parent');20strykerParent.disableTypeCheckingFileMatcher();21const strykerParent = require('stryker-parent');22strykerParent.disableTypeCheckingFileMatcher();23const strykerParent = require('stryker-parent');24strykerParent.disableTypeCheckingFileMatcher();25const strykerParent = require('stryker-parent');26strykerParent.disableTypeCheckingFileMatcher();27const strykerParent = require('stryker-parent');28strykerParent.disableTypeCheckingFileMatcher();29const strykerParent = require('stryker-parent');30strykerParent.disableTypeCheckingFileMatcher();31const strykerParent = require('stryker-parent');32strykerParent.disableTypeCheckingFileMatcher();33const strykerParent = require('stryker-parent');34strykerParent.disableTypeCheckingFileMatcher();35const strykerParent = require('stryker-parent');36strykerParent.disableTypeCheckingFileMatcher();37const strykerParent = require('stryker-parent');38strykerParent.disableTypeCheckingFileMatcher();39const strykerParent = require('stryker-parent');40strykerParent.disableTypeCheckingFileMatcher();41const strykerParent = require('stryker-parent');42strykerParent.disableTypeCheckingFileMatcher();43const strykerParent = require('stryker-parent');44strykerParent.disableTypeCheckingFileMatcher();45const strykerParent = require('stryker-parent');46strykerParent.disableTypeCheckingFileMatcher();

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful