How to use actReportAll 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

...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 // Act...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2var strykerParentObj = new strykerParent();3strykerParentObj.actReportAll();4var strykerParent = require('stryker-parent');5var strykerParentObj = new strykerParent();6strykerParentObj.actReportAll();7var strykerParent = require('stryker-parent');8var strykerParentObj = new strykerParent();9strykerParentObj.actReportAll();10var strykerParent = require('stryker-parent');11var strykerParentObj = new strykerParent();12strykerParentObj.actReportAll();13var strykerParent = require('stryker-parent');14var strykerParentObj = new strykerParent();15strykerParentObj.actReportAll();16var strykerParent = require('stryker-parent');17var strykerParentObj = new strykerParent();18strykerParentObj.actReportAll();19var strykerParent = require('stryker-parent');20var strykerParentObj = new strykerParent();21strykerParentObj.actReportAll();22var strykerParent = require('stryker-parent');23var strykerParentObj = new strykerParent();24strykerParentObj.actReportAll();25var strykerParent = require('stryker-parent');26var strykerParentObj = new strykerParent();27strykerParentObj.actReportAll();28var strykerParent = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2stryker.actReportAll();3{4 "scripts": {5 }6}

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