How to use ignoredMutant method in stryker-parent

Best JavaScript code snippet using stryker-parent

4-mutation-test-executor.ts

Source:4-mutation-test-executor.ts Github

copy

Full Screen

1import { from, partition, merge, Observable, lastValueFrom } from 'rxjs';2import { toArray, map, tap, shareReplay } from 'rxjs/operators';3import { tokens, commonTokens } from '@stryker-mutator/api/plugin';4import { MutantTestCoverage, MutantResult, StrykerOptions, MutantStatus } from '@stryker-mutator/api/core';5import { MutantRunOptions, TestRunner } from '@stryker-mutator/api/test-runner';6import { Logger } from '@stryker-mutator/api/logging';7import { I } from '@stryker-mutator/util';8import { CheckStatus, Checker, CheckResult, PassedCheckResult } from '@stryker-mutator/api/check';9import { coreTokens } from '../di';10import { StrictReporter } from '../reporters/strict-reporter';11import { MutationTestReportHelper } from '../reporters/mutation-test-report-helper';12import { Timer } from '../utils/timer';13import { Pool, ConcurrencyTokenProvider } from '../concurrent';14import { Sandbox } from '../sandbox';15import { DryRunContext } from './3-dry-run-executor';16export interface MutationTestContext extends DryRunContext {17 [coreTokens.testRunnerPool]: I<Pool<TestRunner>>;18 [coreTokens.timeOverheadMS]: number;19 [coreTokens.mutationTestReportHelper]: MutationTestReportHelper;20 [coreTokens.mutantsWithTestCoverage]: MutantTestCoverage[];21}22/**23 * The factor by which hit count from dry run is multiplied to calculate the hit limit for a mutant.24 * This is intentionally a high value to prevent false positives.25 *26 * For example, a property testing library might execute a failing scenario multiple times to determine the smallest possible counterexample.27 * @see https://jsverify.github.io/#minimal-counterexample28 */29const HIT_LIMIT_FACTOR = 100;30export class MutationTestExecutor {31 public static inject = tokens(32 commonTokens.options,33 coreTokens.reporter,34 coreTokens.checkerPool,35 coreTokens.testRunnerPool,36 coreTokens.timeOverheadMS,37 coreTokens.mutantsWithTestCoverage,38 coreTokens.mutationTestReportHelper,39 coreTokens.sandbox,40 commonTokens.logger,41 coreTokens.timer,42 coreTokens.concurrencyTokenProvider43 );44 constructor(45 private readonly options: StrykerOptions,46 private readonly reporter: StrictReporter,47 private readonly checkerPool: I<Pool<Checker>>,48 private readonly testRunnerPool: I<Pool<TestRunner>>,49 private readonly timeOverheadMS: number,50 private readonly matchedMutants: readonly MutantTestCoverage[],51 private readonly mutationTestReportHelper: I<MutationTestReportHelper>,52 private readonly sandbox: I<Sandbox>,53 private readonly log: Logger,54 private readonly timer: I<Timer>,55 private readonly concurrencyTokenProvider: I<ConcurrencyTokenProvider>56 ) {}57 public async execute(): Promise<MutantResult[]> {58 const { ignoredResult$, notIgnoredMutant$ } = this.executeIgnore(from(this.matchedMutants));59 const { passedMutant$, checkResult$ } = this.executeCheck(from(notIgnoredMutant$));60 const { coveredMutant$, noCoverageResult$ } = this.executeNoCoverage(passedMutant$);61 const testRunnerResult$ = this.executeRunInTestRunner(coveredMutant$);62 const results = await lastValueFrom(merge(testRunnerResult$, checkResult$, noCoverageResult$, ignoredResult$).pipe(toArray()));63 this.mutationTestReportHelper.reportAll(results);64 await this.reporter.wrapUp();65 this.logDone();66 return results;67 }68 private executeIgnore(input$: Observable<MutantTestCoverage>) {69 const [ignoredMutant$, notIgnoredMutant$] = partition(input$.pipe(shareReplay()), (mutant) => mutant.status === MutantStatus.Ignored);70 const ignoredResult$ = ignoredMutant$.pipe(map((mutant) => this.mutationTestReportHelper.reportMutantStatus(mutant, MutantStatus.Ignored)));71 return { ignoredResult$, notIgnoredMutant$ };72 }73 private executeNoCoverage(input$: Observable<MutantTestCoverage>) {74 const [noCoverageMatchedMutant$, coveredMutant$] = partition(75 input$.pipe(shareReplay()),76 (mutant) => !mutant.static && (mutant.coveredBy?.length ?? 0) === 077 );78 const noCoverageResult$ = noCoverageMatchedMutant$.pipe(79 map((mutant) => this.mutationTestReportHelper.reportMutantStatus(mutant, MutantStatus.NoCoverage))80 );81 return { noCoverageResult$, coveredMutant$ };82 }83 private executeCheck(input$: Observable<MutantTestCoverage>) {84 const checkTask$ = this.checkerPool85 .schedule(input$, async (checker, mutant) => {86 const checkResult = await checker.check(mutant);87 return {88 checkResult,89 mutant,90 };91 })92 .pipe(93 // Dispose when all checks are completed.94 // This will allow resources to be freed up and more test runners to be spined up.95 tap({96 complete: () => {97 this.checkerPool.dispose();98 this.concurrencyTokenProvider.freeCheckers();99 },100 }),101 shareReplay()102 );103 const [passedCheckResult$, failedCheckResult$] = partition(checkTask$, ({ checkResult }) => checkResult.status === CheckStatus.Passed);104 const checkResult$ = failedCheckResult$.pipe(105 map((failedMutant) =>106 this.mutationTestReportHelper.reportCheckFailed(failedMutant.mutant, failedMutant.checkResult as Exclude<CheckResult, PassedCheckResult>)107 )108 );109 const passedMutant$ = passedCheckResult$.pipe(map(({ mutant }) => mutant));110 return { checkResult$, passedMutant$ };111 }112 private executeRunInTestRunner(input$: Observable<MutantTestCoverage>): Observable<MutantResult> {113 return this.testRunnerPool.schedule(input$, async (testRunner, mutant) => {114 const mutantRunOptions = this.createMutantRunOptions(mutant);115 const result = await testRunner.mutantRun(mutantRunOptions);116 return this.mutationTestReportHelper.reportMutantRunResult(mutant, result);117 });118 }119 private createMutantRunOptions(activeMutant: MutantTestCoverage): MutantRunOptions {120 const timeout = this.options.timeoutFactor * activeMutant.estimatedNetTime + this.options.timeoutMS + this.timeOverheadMS;121 const hitLimit = activeMutant.hitCount === undefined ? undefined : activeMutant.hitCount * HIT_LIMIT_FACTOR;122 return {123 activeMutant,124 timeout,125 testFilter: activeMutant.coveredBy,126 sandboxFileName: this.sandbox.sandboxFileFor(activeMutant.fileName),127 hitLimit,128 disableBail: this.options.disableBail,129 };130 }131 private logDone() {132 this.log.info('Done in %s.', this.timer.humanReadableElapsed());133 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const stryker = require('stryker-parent');2stryker.ignoredMutant('test');3const stryker = require('stryker-parent');4stryker.ignoredMutant('test2');5module.exports = function(config) {6 config.set({7 jest: {8 },9 });10};

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = function (stryker) {2 stryker.on('test-runner-start', function () {3 stryker.ignoredMutant('test.js', 'code to use ignoredMutant method of stryker-parent');4 });5};6module.exports = function (stryker) {7 stryker.on('test-runner-start', function () {8 stryker.ignoredMutant('test.js', 'code to use ignoredMutant method of stryker-child');9 });10};11module.exports = function (config) {12 config.set({13 });14};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { ignoredMutant } = require('stryker-parent');2ignoredMutant('test');3console.log('test');4const { ignoredMutant } = require('stryker-parent');5ignoredMutant('test2');6console.log('test2');7module.exports = function(config) {8 config.set({9 commandRunner: {10 },11 });12};1313:12:29 (1573) INFO Stryker 0 Mutant(s) generated1413:12:29 (1573) INFO Stryker Your mutation score: NaN% (NaN% passed, 0% failed)15When I run the command manually (node test2.js), I get the following output:

Full Screen

Using AI Code Generation

copy

Full Screen

1function ignoredMutant() {2 return true;3}4module.exports = {5};6{7}8{9 "commandRunner": {10 },11}12function ignoredMutant() {13 return true;14}15module.exports = {16};17function ignoredMutant() {18 return true;19}20module.exports = {21};22{23}24function ignoredMutant() {25 return true;26}27module.exports = {28};29function ignoredMutant() {30 return false;31}32module.exports = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var ignoredMutant = require('stryker-parent').ignoredMutant;2var a = 1;3var b = 2;4var c = a + b;5ignoredMutant(c, 'mutant description');6var d = 3;7var e = 4;8var f = d + e;9ignoredMutant(f, 'mutant description');10var g = 5;11var h = 6;12var i = g + h;13ignoredMutant(i, 'mutant description');14var a = 1;15var b = 2;16var c = a + b;17stryker.ignoreMutant(c, 'mutant description');18var d = 3;19var e = 4;20var f = d + e;21stryker.ignoreMutant(f, 'mutant description');22var g = 5;23var h = 6;24var i = g + h;25stryker.ignoreMutant(i, 'mutant description');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ignoredMutant } from 'stryker-parent';2ignoredMutant('this is a mutant to be ignored');3import { ignoredMutant } from 'stryker-parent';4ignoredMutant('this is a mutant to be ignored');5import { ignoredMutant } from 'stryker-parent';6ignoredMutant('this is a mutant to be ignored');7import { ignoredMutant } from 'stryker-parent';8ignoredMutant('this is a mutant to be ignored');9import { ignoredMutant } from 'stryker-parent';10ignoredMutant('this is a mutant to be ignored');11import { ignoredMutant } from 'stryker-parent';12ignoredMutant('this is a mutant to be ignored');13import { ignoredMutant } from 'stryker-parent';14ignoredMutant('this is a mutant to be ignored');15import { ignoredMutant } from 'stryker-parent';16ignoredMutant('this is a mutant to be ignored');17import { ignoredMutant } from 'stryker-parent';18ignoredMutant('this is a mutant to be ignored');19import { ignoredMutant } from 'stryker-parent';20ignoredMutant('this is a mutant to be ignored');21import { ignoredMutant } from 'stryker-parent';22ignoredMutant('this is a mutant to be ignored');23import { ignoredMutant } from 'stryker-parent';

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2stryker.ignoredMutant('test.js', 1, 'mutant 1');3var stryker = require('stryker-parent');4stryker.ignoredMutant('test.js', 2, 'mutant 2');5var stryker = require('stryker-parent');6stryker.ignoredMutant('test.js', 3, 'mutant 3');7var stryker = require('stryker-parent');8stryker.ignoredMutant('test.js', 4, 'mutant 4');9var stryker = require('stryker-parent');10stryker.ignoredMutant('test.js', 5, 'mutant 5');11var stryker = require('stryker-parent');12stryker.ignoredMutant('test.js', 6, 'mutant 6');13var stryker = require('stryker-parent');14stryker.ignoredMutant('test.js', 7, 'mutant 7');15var stryker = require('stryker-parent');16stryker.ignoredMutant('test.js', 8, 'mutant 8');17var stryker = require('stryker-parent');18stryker.ignoredMutant('test.js', 9, 'mutant 9');19var stryker = require('stryker-parent');20stryker.ignoredMutant('test.js', 10, 'mutant 10');

Full Screen

Using AI Code Generation

copy

Full Screen

1const ignoredMutant = require('stryker-parent').ignoredMutant;2ignoredMutant('this is a reason', () => {3});4module.exports = function(config) {5 config.set({6 });7};

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