How to use inputMutants method in stryker-parent

Best JavaScript code snippet using stryker-parent

mutation-test-report-helper.spec.ts

Source:mutation-test-report-helper.spec.ts Github

copy

Full Screen

1import sinon from 'sinon';2import { File, Location, MutantResult, MutantStatus, schema } from '@stryker-mutator/api/core';3import { Reporter } from '@stryker-mutator/api/report';4import { factory, testInjector } from '@stryker-mutator/test-helpers';5import * as strykerUtil from '@stryker-mutator/util';6import { expect } from 'chai';7import { CompleteDryRunResult } from '@stryker-mutator/api/test-runner';8import { CheckStatus } from '@stryker-mutator/api/check';9import { calculateMutationTestMetrics } from 'mutation-testing-metrics';10import { coreTokens } from '../../../src/di';11import { InputFileCollection } from '../../../src/input';12import { MutationTestReportHelper } from '../../../src/reporters/mutation-test-report-helper';13import * as objectUtils from '../../../src/utils/object-utils';14describe(MutationTestReportHelper.name, () => {15 let reporterMock: sinon.SinonStubbedInstance<Required<Reporter>>;16 let inputFiles: InputFileCollection;17 let files: File[];18 let setExitCodeStub: sinon.SinonStub;19 let dryRunResult: CompleteDryRunResult;20 let requireResolveStub: sinon.SinonStub<Parameters<typeof strykerUtil.requireResolve>, ReturnType<typeof strykerUtil.requireResolve>>;21 beforeEach(() => {22 requireResolveStub = sinon.stub(strykerUtil, 'requireResolve');23 reporterMock = factory.reporter();24 setExitCodeStub = sinon.stub(objectUtils, 'setExitCode');25 files = [];26 inputFiles = {27 files,28 filesToMutate: [],29 // eslint-disable-next-line @typescript-eslint/no-empty-function30 logFiles: () => {},31 mutationRanges: [],32 };33 dryRunResult = factory.completeDryRunResult();34 });35 function createSut() {36 return testInjector.injector37 .provideValue(coreTokens.reporter, reporterMock)38 .provideValue(coreTokens.inputFiles, inputFiles)39 .provideValue(coreTokens.dryRunResult, dryRunResult)40 .injectClass(MutationTestReportHelper);41 }42 describe(MutationTestReportHelper.prototype.reportAll.name, () => {43 let sut: MutationTestReportHelper;44 beforeEach(() => {45 sut = createSut();46 });47 it('should report "mutationTestReportReady"', () => {48 sut.reportAll([]);49 expect(reporterMock.onMutationTestReportReady).calledOnce;50 });51 it('should report "onAllMutantsTested"', () => {52 sut.reportAll([]);53 expect(reporterMock.onAllMutantsTested).calledOnce;54 });55 it('should report "onAllMutantsTested" before mutationTestReportReady', () => {56 sut.reportAll([]);57 expect(reporterMock.onAllMutantsTested).calledBefore(reporterMock.onMutationTestReportReady);58 });59 it('should copy thresholds', () => {60 const [actualReport] = actReportAll();61 expect(actualReport.thresholds).eq(testInjector.options.thresholds);62 });63 it('should set correct schema version', () => {64 const [actualReport] = actReportAll();65 expect(actualReport.schemaVersion).eq('1.0');66 });67 it('should add the project root', () => {68 const [actualReport] = actReportAll([]);69 expect(actualReport.projectRoot).eq(process.cwd());70 });71 describe('config', () => {72 it('should report config', () => {73 const [actualReport] = actReportAll([]);74 expect(actualReport.config).eq(testInjector.options);75 });76 });77 describe('framework', () => {78 it('should report "name", "version" and "branding"', () => {79 const expected: Pick<schema.FrameworkInformation, 'branding' | 'name' | 'version'> = {80 name: 'StrykerJS',81 // eslint-disable-next-line @typescript-eslint/no-require-imports82 version: require('../../../../package.json').version,83 branding: {84 homepageUrl: 'https://stryker-mutator.io',85 imageUrl:86 "data:image/svg+xml;utf8,%3Csvg viewBox='0 0 1458 1458' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' clip-rule='evenodd' stroke-linejoin='round' stroke-miterlimit='2'%3E%3Cpath fill='none' d='M0 0h1458v1458H0z'/%3E%3CclipPath id='a'%3E%3Cpath d='M0 0h1458v1458H0z'/%3E%3C/clipPath%3E%3Cg clip-path='url(%23a)'%3E%3Cpath d='M1458 729c0 402.655-326.345 729-729 729S0 1131.655 0 729C0 326.445 326.345 0 729 0s729 326.345 729 729' fill='%23e74c3c' fill-rule='nonzero'/%3E%3Cpath d='M778.349 1456.15L576.6 1254.401l233-105 85-78.668v-64.332l-257-257-44-187-50-208 251.806-82.793L1076.6 389.401l380.14 379.15c-19.681 367.728-311.914 663.049-678.391 687.599z' fill-opacity='.3'/%3E%3Cpath d='M753.4 329.503c41.79 0 74.579 7.83 97.925 25.444 23.571 18.015 41.69 43.956 55.167 77.097l11.662 28.679 165.733-58.183-14.137-32.13c-26.688-60.655-64.896-108.61-114.191-144.011-49.329-35.423-117.458-54.302-204.859-54.302-50.78 0-95.646 7.376-134.767 21.542-40.093 14.671-74.09 34.79-102.239 60.259-28.84 26.207-50.646 57.06-65.496 92.701-14.718 35.052-22.101 72.538-22.101 112.401 0 72.536 20.667 133.294 61.165 182.704 38.624 47.255 98.346 88.037 179.861 121.291 42.257 17.475 78.715 33.125 109.227 46.994 27.193 12.361 49.294 26.124 66.157 41.751 15.309 14.186 26.497 30.584 33.63 49.258 7.721 20.214 11.16 45.69 11.16 76.402 0 28.021-4.251 51.787-13.591 71.219-8.832 18.374-20.171 33.178-34.523 44.219-14.787 11.374-31.193 19.591-49.393 24.466-19.68 5.359-39.14 7.993-58.69 7.993-29.359 0-54.387-3.407-75.182-10.747-20.112-7.013-37.144-16.144-51.259-27.486-13.618-11.009-24.971-23.766-33.744-38.279-9.64-15.8-17.272-31.924-23.032-48.408l-10.965-31.376-161.669 60.585 10.734 30.124c10.191 28.601 24.197 56.228 42.059 82.748 18.208 27.144 41.322 51.369 69.525 72.745 27.695 21.075 60.904 38.218 99.481 51.041 37.777 12.664 82.004 19.159 132.552 19.159 49.998 0 95.818-8.321 137.611-24.622 42.228-16.471 78.436-38.992 108.835-67.291 30.719-28.597 54.631-62.103 71.834-100.642 17.263-38.56 25.923-79.392 25.923-122.248 0-54.339-8.368-100.37-24.208-138.32-16.29-38.759-38.252-71.661-65.948-98.797-26.965-26.418-58.269-48.835-93.858-67.175-33.655-17.241-69.196-33.11-106.593-47.533-35.934-13.429-65.822-26.601-89.948-39.525-22.153-11.868-40.009-24.21-53.547-37.309-11.429-11.13-19.83-23.678-24.718-37.664-5.413-15.49-7.98-33.423-7.98-53.577 0-40.883 11.293-71.522 37.086-90.539 28.443-20.825 64.985-30.658 109.311-30.658z' fill='%23f1c40f' fill-rule='nonzero'/%3E%3Cpath d='M720 0h18v113h-18zM1458 738v-18h-113v18h113zM720 1345h18v113h-18zM113 738v-18H0v18h113z'/%3E%3C/g%3E%3C/svg%3E",87 },88 };89 const [actualReport] = actReportAll([]);90 expect(actualReport.framework).deep.include(expected);91 });92 it('should report "dependencies"', () => {93 // Arrange94 const expectedDependencies: schema.Dependencies = {95 '@stryker-mutator/mocha-runner': '1.0.1',96 '@stryker-mutator/karma-runner': '1.0.2',97 '@stryker-mutator/jasmine-runner': '1.0.3',98 '@stryker-mutator/jest-runner': '1.0.4',99 '@stryker-mutator/typescript-checker': '1.0.5',100 karma: '1.0.6',101 'karma-chai': '1.0.7',102 'karma-chrome-launcher': '1.0.8',103 'karma-jasmine': '1.0.9',104 'karma-mocha': '1.0.10',105 mocha: '1.0.11',106 jasmine: '1.0.12',107 'jasmine-core': '1.0.13',108 jest: '1.0.14',109 'react-scripts': '1.0.15',110 typescript: '1.0.16',111 '@angular/cli': '1.0.17',112 webpack: '1.0.18',113 'webpack-cli': '1.0.19',114 'ts-jest': '1.0.20',115 };116 Object.entries(expectedDependencies).forEach(([dep, version]) => requireResolveStub.withArgs(`${dep}/package.json`).returns({ version }));117 // Act118 const [actualReport] = actReportAll([]);119 // Assert120 expect(actualReport.framework?.dependencies).deep.eq(expectedDependencies);121 });122 it('should ignore dependencies that could not be found', () => {123 // Arrange124 requireResolveStub.withArgs('karma/package.json').returns({ version: '2.3.4' });125 requireResolveStub.withArgs('typescript/package.json').throws(new Error('[MODULE_NOT_FOUND]: Cannot find module "typescript"'));126 // Act127 const [actualReport] = actReportAll([]);128 // Assert129 expect(actualReport.framework?.dependencies).deep.eq({ karma: '2.3.4' });130 });131 });132 describe('system under test', () => {133 it('should correctly map system under test file properties', () => {134 // Arrange135 files.push(new File('foo.js', 'foo content'));136 files.push(new File('bar.html', 'bar content'));137 files.push(new File('baz.vue', 'baz content'));138 files.push(new File('qux.ts', 'qux content'));139 files.push(new File('corge.tsx', 'corge content'));140 const inputMutants = files.map((file) => factory.killedMutantResult({ fileName: file.name }));141 // Act142 const [actualReport] = actReportAll(inputMutants);143 // Assert144 expect(Object.keys(actualReport.files)).lengthOf(5);145 expect(actualReport.files['foo.js']).include({ language: 'javascript', source: 'foo content' });146 expect(actualReport.files['bar.html']).include({ language: 'html', source: 'bar content' });147 expect(actualReport.files['baz.vue']).include({ language: 'html', source: 'baz content' });148 expect(actualReport.files['qux.ts']).include({ language: 'typescript', source: 'qux content' });149 expect(actualReport.files['corge.tsx']).include({ language: 'typescript', source: 'corge content' });150 });151 it('should correctly map basic MutantResult properties', () => {152 // Arrange153 const killedMutantResult: MutantResult = {154 id: '1',155 mutatorName: 'Foo',156 replacement: 'foo replacement',157 fileName: 'foo.js',158 description: 'this is mutant foo',159 duration: 42,160 location: factory.location(),161 static: true,162 statusReason: 'smacked on the head',163 testsCompleted: 32,164 status: MutantStatus.Killed,165 };166 const inputMutants = [167 killedMutantResult,168 factory.mutantResult({169 fileName: 'bar.js',170 status: MutantStatus.NoCoverage,171 }),172 factory.mutantResult({173 fileName: 'baz.js',174 status: MutantStatus.RuntimeError,175 }),176 factory.mutantResult({177 fileName: 'qux.js',178 status: MutantStatus.Survived,179 }),180 factory.mutantResult({181 fileName: '5.js',182 status: MutantStatus.Timeout,183 }),184 factory.mutantResult({185 fileName: '6.js',186 status: MutantStatus.CompileError,187 }),188 ];189 files.push(...inputMutants.map((m) => new File(m.fileName, '')));190 // Act191 const [actualReport] = actReportAll(inputMutants);192 // Assert193 const expectedKilledMutant: Partial<schema.MutantResult> = {194 id: '1',195 mutatorName: 'Foo',196 replacement: 'foo replacement',197 description: 'this is mutant foo',198 duration: 42,199 static: true,200 statusReason: 'smacked on the head',201 testsCompleted: 32,202 status: MutantStatus.Killed,203 };204 expect(Object.keys(actualReport.files)).lengthOf(6);205 expect(actualReport.files['foo.js'].mutants[0]).include(expectedKilledMutant);206 expect(actualReport.files['bar.js'].mutants[0]).include({ status: MutantStatus.NoCoverage });207 expect(actualReport.files['baz.js'].mutants[0]).include({ status: MutantStatus.RuntimeError });208 expect(actualReport.files['qux.js'].mutants[0]).include({ status: MutantStatus.Survived });209 expect(actualReport.files['5.js'].mutants[0]).include({ status: MutantStatus.Timeout });210 expect(actualReport.files['6.js'].mutants[0]).include({ status: MutantStatus.CompileError });211 });212 it('should offset location correctly', () => {213 const inputMutants = [factory.mutantResult({ location: { end: { line: 3, column: 4 }, start: { line: 1, column: 2 } } })];214 files.push(...inputMutants.map((m) => new File(m.fileName, '')));215 const [actualReport] = actReportAll(inputMutants);216 expect(actualReport.files['file.js'].mutants[0].location).deep.eq({ end: { line: 4, column: 5 }, start: { line: 2, column: 3 } });217 });218 it('should group mutants by file name', () => {219 // Arrange220 const inputMutants = [221 factory.mutantResult({222 mutatorName: 'Foo',223 fileName: 'foo.js',224 }),225 factory.mutantResult({226 mutatorName: 'Bar',227 fileName: 'foo.js',228 }),229 ];230 files.push(new File('foo.js', ''));231 // Act232 const [actualReport] = actReportAll(inputMutants);233 // Assert234 expect(Object.keys(actualReport.files)).lengthOf(1);235 expect(actualReport.files['foo.js'].mutants).lengthOf(2);236 });237 it('should log a warning if source file could not be found', () => {238 const inputMutants = [factory.killedMutantResult({ fileName: 'not-found.js' })];239 const [actualReport] = actReportAll(inputMutants);240 expect(actualReport.files['not-found.js'].mutants).lengthOf(1);241 expect(testInjector.logger.warn).calledWithMatch('File "not-found.js" not found');242 });243 });244 describe('tests', () => {245 it('should correctly provide test file properties', () => {246 // Arrange247 dryRunResult.tests.push(factory.testResult({ id: 'spec1', name: 'dog should not eat dog', fileName: 'foo.spec.js' }));248 files.push(new File('foo.js', 'foo content'), new File('foo.spec.js', 'it("dog should not eat dog")'), new File('baz.js', 'baz content'));249 // Act250 const [actualReport] = actReportAll();251 // Assert252 expect(actualReport.testFiles?.['foo.spec.js'].source).eq('it("dog should not eat dog")');253 });254 it('should report the tests in `testFiles`', () => {255 // Arrange256 dryRunResult.tests.push(257 factory.testResult({ id: 'spec1', name: 'dog should not eat dog' }),258 factory.testResult({ id: 'spec2', name: 'dog should chase its own tail', startPosition: { line: 5, column: 0 } })259 );260 // Act261 const [actualReport] = actReportAll([]);262 // Assert263 const expected: schema.TestFileDefinitionDictionary = {264 ['']: {265 tests: [266 { id: '0', name: 'dog should not eat dog', location: undefined },267 { id: '1', name: 'dog should chase its own tail', location: { start: { line: 6, column: 1 } } }, // mutation testing elements uses offset 1 for both line and column268 ],269 },270 };271 expect(actualReport.testFiles).deep.eq(expected);272 });273 it('should remap test ids if possible (for brevity, since mocha, jest and karma use test titles as test ids)', () => {274 // Arrange275 dryRunResult.tests.push(276 factory.testResult({ id: 'foo should bar', name: 'foo should bar' }),277 factory.testResult({ id: 'baz should qux', name: 'baz should qux' })278 );279 const killedMutantResult = factory.mutantResult({280 fileName: 'foo.js',281 killedBy: ['foo should bar'],282 coveredBy: ['foo should bar', 'baz should qux', 'not found'],283 });284 files.push(new File('foo.js', ''));285 // Act286 const [actualReport] = actReportAll([killedMutantResult]);287 // Assert288 const expectedTests: schema.TestDefinition[] = [289 { id: '0', name: 'foo should bar', location: undefined },290 { id: '1', name: 'baz should qux', location: undefined },291 ];292 const actualResultMutant = actualReport.files['foo.js'].mutants[0];293 expect(actualReport.testFiles?.[''].tests).deep.eq(expectedTests);294 expect(actualResultMutant.coveredBy).deep.eq(['0', '1', 'not found']);295 expect(actualResultMutant.killedBy).deep.eq(['0']);296 });297 it('should group test by test file name', () => {298 // Arrange299 dryRunResult.tests.push(300 factory.testResult({ fileName: 'foo.spec.js', name: '1' }),301 factory.testResult({ fileName: 'bar.spec.js', name: '2' }),302 factory.testResult({ fileName: 'foo.spec.js', name: '3' })303 );304 files.push(new File('foo.spec.js', ''), new File('bar.spec.js', ''));305 // Act306 const [actualReport] = actReportAll([]);307 // Assert308 expect(Object.keys(actualReport.testFiles!)).lengthOf(2);309 expect(actualReport.testFiles!['foo.spec.js'].tests).lengthOf(2);310 expect(actualReport.testFiles!['foo.spec.js'].tests[0].name).eq('1');311 expect(actualReport.testFiles!['foo.spec.js'].tests[1].name).eq('3');312 expect(actualReport.testFiles!['bar.spec.js'].tests[0].name).eq('2');313 });314 it('should log a warning the test file could not be found', () => {315 dryRunResult.tests.push(factory.testResult({ fileName: 'foo.spec.js' }));316 actReportAll([]);317 expect(testInjector.logger.warn).calledWithMatch('Test file "foo.spec.js" not found in input files');318 });319 });320 it('should provide the metrics as second argument', () => {321 // Arrange322 const inputMutants: MutantResult[] = [323 {324 mutatorName: 'Foo',325 fileName: 'foo.js',326 status: MutantStatus.Killed,327 location: { start: { line: 1, column: 2 }, end: { line: 4, column: 5 } },328 replacement: '+',329 id: '1',330 },331 ];332 files.push(new File('foo.js', ''));333 dryRunResult.tests.push(factory.testResult({ id: 'foo should bar', name: 'foo should bar' }));334 // Act335 const [actualReport, metrics] = actReportAll(inputMutants);336 // Assert337 expect(metrics).deep.eq(calculateMutationTestMetrics(actualReport));338 });339 describe('determineExitCode', () => {340 beforeEach(() => {341 files.push(new File('file.js', ''));342 });343 it('should not set exit code = 1 if `threshold.break` is not configured', () => {344 actReportAll([factory.mutantResult({ status: MutantStatus.Survived })]);345 expect(setExitCodeStub).not.called;346 expect(testInjector.logger.debug).calledWith(347 "No breaking threshold configured. Won't fail the build no matter how low your mutation score is. Set `thresholds.break` to change this behavior."348 );349 });350 it('should not set exit code = 1 if `threshold.break` === score', () => {351 testInjector.options.thresholds.break = 50;352 actReportAll([factory.mutantResult({ status: MutantStatus.Survived }), factory.mutantResult({ status: MutantStatus.Killed })]); // 50 %353 expect(setExitCodeStub).not.called;354 expect(testInjector.logger.info).calledWith('Final mutation score of 50.00 is greater than or equal to break threshold 50');355 });356 it('should set exit code = 1 if `threshold.break` > score', () => {357 testInjector.options.thresholds.break = 50.01;358 actReportAll([factory.mutantResult({ status: MutantStatus.Survived }), factory.mutantResult({ status: MutantStatus.Killed })]); // 50 %359 expect(setExitCodeStub).calledWith(1);360 expect(testInjector.logger.error).calledWith('Final mutation score 50.00 under breaking threshold 50.01, setting exit code to 1 (failure).');361 expect(testInjector.logger.info).calledWith('(improve mutation score or set `thresholds.break = null` to prevent this error in the future)');362 });363 });364 function actReportAll(input: MutantResult[] = []): Parameters<Required<Reporter>['onMutationTestReportReady']> {365 sut.reportAll(input);366 return reporterMock.onMutationTestReportReady.firstCall.args;367 }368 });369 describe('reportOne', () => {370 beforeEach(() => {371 inputFiles = new InputFileCollection([new File('add.js', 'function add(a, b) {\n return a + b;\n}\n')], ['add.js'], []);372 });373 describe(MutationTestReportHelper.prototype.reportCheckFailed.name, () => {374 it('should map simple attributes to the mutant result', () => {375 // Arrange376 const sut = createSut();377 const location: Location = Object.freeze({ start: Object.freeze({ line: 1, column: 5 }), end: Object.freeze({ line: 3, column: 1 }) });378 // Act379 const actual = sut.reportCheckFailed(380 factory.mutant({381 id: '32',382 fileName: 'add.js',383 location,384 replacement: '{}',385 mutatorName: 'fooMutator',386 }),387 factory.failedCheckResult()388 );389 // Assert390 const expected: Partial<MutantResult> = {391 id: '32',392 location,393 mutatorName: 'fooMutator',394 fileName: 'add.js',395 replacement: '{}',396 };397 expect(actual).include(expected);398 });399 it('should report statusReason', () => {400 // Arrange401 const sut = createSut();402 // Act403 const actual = sut.reportCheckFailed(404 factory.mutant({ fileName: 'add.js' }),405 factory.failedCheckResult({ status: CheckStatus.CompileError, reason: 'cannot call foo of undefined' })406 );407 // Assert408 const expected: Partial<MutantResult> = {409 status: MutantStatus.CompileError,410 statusReason: 'cannot call foo of undefined',411 };412 expect(actual).include(expected);413 });414 });415 describe(MutationTestReportHelper.prototype.reportMutantStatus.name, () => {416 it('should correctly map all properties', () => {417 // Arrange418 const input = factory.mutantTestCoverage({419 fileName: 'add.js',420 id: '3',421 location: factory.location(),422 mutatorName: 'fooMutator',423 replacement: '"bar"',424 coveredBy: ['1'],425 static: false,426 });427 const sut = createSut();428 // Act429 const actual = sut.reportMutantStatus(input, MutantStatus.NoCoverage);430 // Assert431 const expected: MutantResult = {432 status: MutantStatus.NoCoverage,433 fileName: 'add.js',434 id: '3',435 location: factory.location(),436 mutatorName: 'fooMutator',437 replacement: '"bar"',438 coveredBy: ['1'],439 static: false,440 };441 expect(actual).deep.include(expected);442 });443 });444 describe(MutationTestReportHelper.prototype.reportMutantRunResult.name, () => {445 it('should report a killed mutant when called with a KilledMutantRunResult', () => {446 // Arrange447 dryRunResult.tests.push(factory.failedTestResult({ id: '1', name: 'foo should be bar' }));448 const sut = createSut();449 // Act450 const actual = sut.reportMutantRunResult(451 factory.mutantTestCoverage({ fileName: 'add.js' }),452 factory.killedMutantRunResult({ killedBy: '1', nrOfTests: 42, failureMessage: 'foo should have been bar at line 1' })453 );454 // Assert455 const expected: Partial<MutantResult> = {456 status: MutantStatus.Killed,457 killedBy: ['1'],458 testsCompleted: 42,459 statusReason: 'foo should have been bar at line 1',460 };461 expect(actual).deep.include(expected);462 });463 it('should report a killed mutant when called with a KilledMutantRunResult with KilledBy as array', () => {464 // Arrange465 dryRunResult.tests.push(factory.failedTestResult({ id: '1', name: 'foo should be bar' }));466 const sut = createSut();467 // Act468 const actual = sut.reportMutantRunResult(469 factory.mutantTestCoverage({ fileName: 'add.js' }),470 factory.killedMutantRunResult({ killedBy: ['1', '2'], nrOfTests: 42, failureMessage: 'foo should have been bar at line 1' })471 );472 // Assert473 const expected: Partial<MutantResult> = {474 status: MutantStatus.Killed,475 killedBy: ['1', '2'],476 testsCompleted: 42,477 statusReason: 'foo should have been bar at line 1',478 };479 expect(actual).deep.include(expected);480 });481 it('should report a runtime error when called with an ErrorMutantRunResult', () => {482 // Arrange483 const sut = createSut();484 // Act485 const actual = sut.reportMutantRunResult(486 factory.mutantTestCoverage({ fileName: 'add.js' }),487 factory.errorMutantRunResult({ errorMessage: 'Cannot call foo of null' })488 );489 // Assert490 const expected: Partial<MutantResult> = {491 status: MutantStatus.RuntimeError,492 statusReason: 'Cannot call foo of null',493 };494 expect(actual).deep.include(expected);495 });496 it('should report a timeout mutant when called with a TimeoutMutantRunResult', () => {497 // Arrange498 const sut = createSut();499 // Act500 const actual = sut.reportMutantRunResult(factory.mutantTestCoverage({ fileName: 'add.js' }), factory.timeoutMutantRunResult());501 // Assert502 const expected: Partial<MutantResult> = {503 status: MutantStatus.Timeout,504 };505 expect(actual).deep.include(expected);506 });507 it('should report a survived mutant when called with a SurvivedMutantRunResult', () => {508 // Arrange509 dryRunResult.tests.push(factory.failedTestResult({ id: '1', name: 'foo should be bar' }));510 const sut = createSut();511 // Act512 const actual = sut.reportMutantRunResult(513 factory.mutantTestCoverage({ fileName: 'add.js', coveredBy: ['1'] }),514 factory.survivedMutantRunResult({ nrOfTests: 4 })515 );516 // Assert517 const expected: Partial<MutantResult> = {518 status: MutantStatus.Survived,519 coveredBy: ['1'],520 testsCompleted: 4,521 };522 expect(actual).deep.include(expected);523 });524 it('should be able to report coveredBy as `undefined` for a survived mutant', () => {525 // Arrange526 dryRunResult.tests.push(factory.failedTestResult({ id: '1', name: 'foo should be bar' }));527 const sut = createSut();528 // Act529 const actual = sut.reportMutantRunResult(530 factory.mutantTestCoverage({ fileName: 'add.js', coveredBy: undefined }),531 factory.survivedMutantRunResult()532 );533 // Assert534 const expected: Partial<MutantResult> = {535 status: MutantStatus.Survived,536 coveredBy: undefined,537 };538 expect(actual).deep.include(expected);539 });540 });541 });...

Full Screen

Full Screen

mutantsEntry.js

Source:mutantsEntry.js Github

copy

Full Screen

1import React, { useContext, useState } from "react";2import InputMutants from "../components/inputMutants/inputMutants";3import FavoriteItem from "../components/Favorites/FavoriteItem";4import CheckCircleTwoToneIcon from "@material-ui/icons/CheckCircleTwoTone";5import Grid from "@material-ui/core/Grid";6import { MutantsContext } from "../context/mutants-context";7import "./mutantsEntry.css"8const MutantsEntry = (props) => {9 const [mutantList, setMutantList] = useContext(MutantsContext);10 const [newMutantAdded, setNewAddedMutant] = useState(false);11 const setMutant = (NewM) => {12 setMutantList((currentMutants) => [...currentMutants, NewM]);13 setNewAddedMutant(true);14 };15 const addNewMutantAgainHandler = () =>{16 setNewAddedMutant(false)17 };18 return (19 <div className="">20 {!newMutantAdded ? (21 <div className="add-new-mutant">22 <h2>Registrar nuevo mutante</h2>23 <InputMutants setNewMutant={setMutant} />24 </div>25 ) : (26 <div className="succed-Added">27 <CheckCircleTwoToneIcon28 style={{ color: "green", fontSize: 30 }}29 />30 <h2 className="">Mutante Agregado</h2>31 <button onClick={addNewMutantAgainHandler}>32 Agregar otro mutante33 </button>34 </div>35 )}36 </div>37 );38};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1const { inputMutants } = require('stryker-parent');2const { inputMutants } = require('stryker-parent');3const mutants = inputMutants();4mutants.forEach(mutant => {5 console.log(mutant);6});7module.exports = function (config) {8 config.set({9 mochaOptions: {10 }11 });12};13> 17:46:16 (13037) INFO MochaTestRunner Using Mocha 3.2.0 as test runner14> 17:46:16 (13037) INFO MochaTestRunner Loading test files using Mocha's require: ["test.js"]15> at InitialTestExecutor.determineExitCode (C:\Users\

Full Screen

Using AI Code Generation

copy

Full Screen

1var inputMutants = require('stryker-parent').inputMutants;2inputMutants({3 {pattern: 'test.js', mutated: true, included: true},4 {pattern: 'src.js', mutated: false, included: true}5});6function add(a, b) {7 return a + b;8}9describe('add', function() {10 it('should add 2 numbers', function() {11 expect(add(2, 2)).toBe(4);12 });13});14module.exports = function(config) {15 config.set({16 karma: {17 config: {18 }19 }20 });21};22The Stryker API is a way to use Stryker from the command line or from your own code. It is a facade for the [Stryker CLI](packages/stryker-cli/README.md). It exposes the following methods:23 * @param {Object} options - The options to use24 * @param {Object} [options.configFile] - The path to the stryker.conf.js file. The options object will be merged with the config file25 * @param {string} [options.logLevel] - The log level to use. Defaults to "info"26 * @param {string} [options.logLevel] - The log level to use. Defaults to "info"27 * @param {string[]} [options.plugins] - The plugins to load. Defaults to []28 * @param {Object} [options.port] - The port to use for the test runner. Defaults to 923429 * @param {string} [options.tmpDirName

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var inputMutants = require('stryker-parent').inputMutants;2inputMutants(function (mutant) {3});4var inputMutants = require('stryker-parent').inputMutants;5inputMutants(function (mutant) {6});7var inputMutants = require('stryker-parent').inputMutants;8inputMutants(function (mutant) {9});10var inputMutants = require('stryker-parent').inputMutants;11inputMutants(function (mutant) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var inputMutants = stryker.inputMutants;3var mutants = inputMutants();4console.log(mutants);5module.exports = function(config) {6 config.set({7 jest: {8 }9 });10};11module.exports = {12 coverageThreshold: {13 global: {14 }15 },16 globals: {17 'ts-jest': {18 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var inputMutants = require('stryker-parent').inputMutants;2inputMutants(function (mutant) {3 console.log(mutant);4});5var outputMutantResult = require('stryker-parent').outputMutantResult;6outputMutantResult({7 originalLines: ['var a = 1;'],8 mutatedLines: ['var a = 2;'],9 mutatedCode: 'var a = 2;',10});11var outputAllMutantsTested = require('stryker-parent').outputAllMutantsTested;12outputAllMutantsTested();13var outputScore = require('stryker-parent').outputScore;14outputScore(80);15var outputError = require('stryker-parent').outputError;16outputError('error');17var outputDone = require('stryker-parent').outputDone;18outputDone();19var outputTimeout = require('stryker-parent').outputTimeout;20outputTimeout();21var outputCoverageAnalysis = require('stryker-parent').outputCoverageAnalysis;22outputCoverageAnalysis('perTest');23var outputMutantFilter = require('stryker-parent').outputMutantFilter;24outputMutantFilter(['1', '2', '3']);25var outputMutantRunResult = require('stryker-parent').outputMutantRunResult;26outputMutantRunResult({27 originalLines: ['var a = 1;'],28 mutatedLines: ['var a = 2;'],29 mutatedCode: 'var a = 2;',

Full Screen

Using AI Code Generation

copy

Full Screen

1const inputMutants = require('stryker-parent').inputMutants;2inputMutants('test.js', mutants, (mutant) => {3 const mutatedSourceCode = sourceCode.substr(0, mutant.range[0]) + mutant.replacement + sourceCode.substr(mutant.range[1]);4 const result = runTests(mutatedSourceCode);5 return result;6});7Apache-2.0 © [Nico Jansen](

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