How to use actualDryRunResult method in stryker-parent

Best JavaScript code snippet using stryker-parent

3-dry-run-executor.spec.ts

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

copy

Full Screen

1import { EOL } from 'os';2import { Injector } from 'typed-inject';3import { assertions, factory, testInjector } from '@stryker-mutator/test-helpers';4import sinon from 'sinon';5import { TestRunner, CompleteDryRunResult, ErrorDryRunResult, TimeoutDryRunResult, DryRunResult } from '@stryker-mutator/api/test-runner';6import { expect } from 'chai';7import { Observable } from 'rxjs';8import { mergeMap } from 'rxjs/operators';9import { I } from '@stryker-mutator/util';10import { Timer } from '../../../src/utils/timer';11import { DryRunContext, DryRunExecutor, MutationTestContext } from '../../../src/process';12import { coreTokens } from '../../../src/di';13import { ConfigError } from '../../../src/errors';14import { ConcurrencyTokenProvider, Pool } from '../../../src/concurrent';15import { createTestRunnerPoolMock } from '../../helpers/producers';16import { Sandbox } from '../../../src/sandbox';17describe(DryRunExecutor.name, () => {18 let injectorMock: sinon.SinonStubbedInstance<Injector<MutationTestContext>>;19 let testRunnerPoolMock: sinon.SinonStubbedInstance<Pool<TestRunner>>;20 let sut: DryRunExecutor;21 let timerMock: sinon.SinonStubbedInstance<Timer>;22 let testRunnerMock: sinon.SinonStubbedInstance<Required<TestRunner>>;23 let concurrencyTokenProviderMock: sinon.SinonStubbedInstance<ConcurrencyTokenProvider>;24 let sandbox: sinon.SinonStubbedInstance<Sandbox>;25 beforeEach(() => {26 timerMock = sinon.createStubInstance(Timer);27 testRunnerMock = factory.testRunner();28 testRunnerPoolMock = createTestRunnerPoolMock();29 (30 testRunnerPoolMock.schedule as sinon.SinonStub<31 [Observable<unknown>, (testRunner: TestRunner, arg: unknown) => Promise<DryRunResult>],32 Observable<DryRunResult>33 >34 ).callsFake((item$, task) => item$.pipe(mergeMap((item) => task(testRunnerMock, item))));35 concurrencyTokenProviderMock = sinon.createStubInstance(ConcurrencyTokenProvider);36 injectorMock = factory.injector();37 injectorMock.resolve.withArgs(coreTokens.testRunnerPool).returns(testRunnerPoolMock as I<Pool<TestRunner>>);38 sandbox = sinon.createStubInstance(Sandbox);39 sut = new DryRunExecutor(40 injectorMock as Injector<DryRunContext>,41 testInjector.logger,42 testInjector.options,43 timerMock,44 concurrencyTokenProviderMock,45 sandbox46 );47 });48 it('should pass through any rejections', async () => {49 const expectedError = new Error('expected error');50 testRunnerMock.dryRun.rejects(expectedError);51 await expect(sut.execute()).rejectedWith(expectedError);52 });53 describe('check timeout', () => {54 let runResult: CompleteDryRunResult;55 beforeEach(() => {56 runResult = factory.completeDryRunResult();57 testRunnerMock.dryRun.resolves(runResult);58 runResult.tests.push(factory.successTestResult());59 });60 it('should use the configured timeout in ms if option provided', async () => {61 testInjector.options.dryRunTimeoutMinutes = 7.5;62 const timeoutMS = testInjector.options.dryRunTimeoutMinutes * 60 * 1000;63 await sut.execute();64 expect(testRunnerMock.dryRun).calledWithMatch({65 timeout: timeoutMS,66 });67 });68 it('should use the default timeout value if option not provided', async () => {69 const defaultTimeoutMS = 5 * 60 * 1000;70 await sut.execute();71 expect(testRunnerMock.dryRun).calledWithMatch({72 timeout: defaultTimeoutMS,73 });74 });75 });76 describe('disable bail', () => {77 let runResult: CompleteDryRunResult;78 beforeEach(() => {79 runResult = factory.completeDryRunResult();80 testRunnerMock.dryRun.resolves(runResult);81 runResult.tests.push(factory.successTestResult());82 });83 it('should bail by default', async () => {84 await sut.execute();85 expect(testRunnerMock.dryRun).calledWithMatch({86 disableBail: false,87 });88 });89 it('should bail when given the option', async () => {90 testInjector.options.disableBail = true;91 await sut.execute();92 expect(testRunnerMock.dryRun).calledWithMatch({93 disableBail: true,94 });95 });96 });97 describe('when the dryRun completes', () => {98 let runResult: CompleteDryRunResult;99 beforeEach(() => {100 runResult = factory.completeDryRunResult();101 testRunnerMock.dryRun.resolves(runResult);102 });103 it('should log about that this might take a while', async () => {104 runResult.tests.push(factory.successTestResult());105 await sut.execute();106 expect(testInjector.logger.info).calledWith(107 'Starting initial test run (command test runner with "perTest" coverage analysis). This may take a while.'108 );109 });110 describe('with successful tests', () => {111 it('should calculate the overhead time milliseconds', async () => {112 // Arrange113 runResult.tests.push(factory.successTestResult({ timeSpentMs: 10 }));114 runResult.tests.push(factory.successTestResult({ timeSpentMs: 2 }));115 runResult.tests.push(factory.successTestResult({ timeSpentMs: 6 }));116 const expectedOverHeadTimeMs = 82;117 timerMock.elapsedMs.returns(100);118 // Act119 const actualResultInjector = await sut.execute();120 // Assert121 expect(timerMock.mark).calledWith('Initial test run');122 expect(timerMock.elapsedMs).calledWith('Initial test run');123 expect(timerMock.mark).calledBefore(timerMock.elapsedMs);124 expect(actualResultInjector.provideValue).calledWithExactly(coreTokens.timeOverheadMS, expectedOverHeadTimeMs);125 });126 it('should never calculate a negative overhead time', async () => {127 runResult.tests.push(factory.successTestResult({ timeSpentMs: 10 }));128 timerMock.elapsedMs.returns(9);129 const injector = await sut.execute();130 expect(injector.provideValue).calledWithExactly(coreTokens.timeOverheadMS, 0);131 });132 it('should provide the dry run result', async () => {133 timerMock.elapsedMs.returns(42);134 runResult.tests.push(factory.successTestResult());135 runResult.mutantCoverage = {136 perTest: {},137 static: {},138 };139 const actualInjector = await sut.execute();140 expect(actualInjector.provideValue).calledWithExactly(coreTokens.dryRunResult, runResult);141 });142 it('should remap test files that are reported', async () => {143 runResult.tests.push(factory.successTestResult({ fileName: '.stryker-tmp/sandbox-123/test/foo.spec.js' }));144 sandbox.originalFileFor.returns('test/foo.spec.js');145 await sut.execute();146 const actualDryRunResult = injectorMock.provideValue.getCalls().find((call) => call.args[0] === coreTokens.dryRunResult)!147 .args[1] as DryRunResult;148 assertions.expectCompleted(actualDryRunResult);149 expect(actualDryRunResult.tests[0].fileName).eq('test/foo.spec.js');150 expect(sandbox.originalFileFor).calledWith('.stryker-tmp/sandbox-123/test/foo.spec.js');151 });152 it('should remap test locations when type checking was disabled for a test file', async () => {153 runResult.tests.push(154 factory.successTestResult({ fileName: '.stryker-tmp/sandbox-123/test/foo.spec.js', startPosition: { line: 3, column: 1 } }),155 factory.successTestResult({ fileName: '.stryker-tmp/sandbox-123/testResources/foo.spec.js', startPosition: { line: 5, column: 1 } })156 );157 sandbox.originalFileFor158 .withArgs('.stryker-tmp/sandbox-123/test/foo.spec.js')159 .returns('test/foo.spec.js')160 .withArgs('.stryker-tmp/sandbox-123/testResources/foo.spec.js')161 .returns('testResources/foo.spec.js');162 await sut.execute();163 const actualDryRunResult = injectorMock.provideValue.getCalls().find((call) => call.args[0] === coreTokens.dryRunResult)!164 .args[1] as DryRunResult;165 assertions.expectCompleted(actualDryRunResult);166 expect(actualDryRunResult.tests[0].startPosition).deep.eq({ line: 2, column: 1 });167 expect(actualDryRunResult.tests[1].startPosition).deep.eq({ line: 5, column: 1 }); // should not have been remapped, since type checking wasn't disabled here168 });169 it('should have logged the amount of tests ran', async () => {170 runResult.tests.push(factory.successTestResult({ timeSpentMs: 10 }));171 runResult.tests.push(factory.successTestResult({ timeSpentMs: 10 }));172 timerMock.humanReadableElapsed.returns('30 seconds');173 timerMock.humanReadableElapsed.withArgs('Initial test run').returns('2 seconds');174 timerMock.elapsedMs.returns(30000);175 timerMock.elapsedMs.withArgs('Initial test run').returns(2000);176 await sut.execute();177 expect(testInjector.logger.info).to.have.been.calledWith(178 'Initial test run succeeded. Ran %s tests in %s (net %s ms, overhead %s ms).',179 2,180 '2 seconds',181 20,182 1980183 );184 });185 it('should log when there were no tests', async () => {186 await expect(sut.execute()).rejectedWith(187 ConfigError,188 'No tests were executed. Stryker will exit prematurely. Please check your configuration.'189 );190 });191 });192 describe('with failed tests', () => {193 beforeEach(() => {194 runResult.tests.push(factory.failedTestResult({ name: 'foo is bar', failureMessage: 'foo was baz' }));195 runResult.tests.push(factory.failedTestResult({ name: 'bar is baz', failureMessage: 'bar was qux' }));196 });197 it('should have logged the errors', async () => {198 await expect(sut.execute()).rejected;199 expect(testInjector.logger.error).calledWith(200 `One or more tests failed in the initial test run:${EOL}\tfoo is bar${EOL}\t\tfoo was baz${EOL}\tbar is baz${EOL}\t\tbar was qux`201 );202 });203 it('should reject with correct message', async () => {204 await expect(sut.execute()).rejectedWith(ConfigError, 'There were failed tests in the initial test run.');205 });206 });207 });208 describe('when dryRun errors', () => {209 let runResult: ErrorDryRunResult;210 beforeEach(() => {211 runResult = factory.errorDryRunResult();212 testRunnerMock.dryRun.resolves(runResult);213 });214 it('should have logged the errors', async () => {215 runResult.errorMessage = 'cannot call foo() on undefined';216 await expect(sut.execute()).rejected;217 expect(testInjector.logger.error).calledWith(`One or more tests resulted in an error:${EOL}\tcannot call foo() on undefined`);218 });219 it('should reject with correct message', async () => {220 await expect(sut.execute()).rejectedWith('Something went wrong in the initial test run');221 });222 });223 describe('when dryRun timedOut', () => {224 let runResult: TimeoutDryRunResult;225 beforeEach(() => {226 runResult = factory.timeoutDryRunResult();227 testRunnerMock.dryRun.resolves(runResult);228 });229 it('should have logged the timeout', async () => {230 await expect(sut.execute()).rejected;231 expect(testInjector.logger.error).calledWith('Initial test run timed out!');232 });233 it('should reject with correct message', async () => {234 await expect(sut.execute()).rejectedWith('Something went wrong in the initial test run');235 });236 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = function (config) {2 config.set({3 mochaOptions: {4 }5 });6};

Full Screen

Using AI Code Generation

copy

Full Screen

1var actualDryRunResult = require('stryker-parent').actualDryRunResult;2var dryRunResult = actualDryRunResult();3console.log(dryRunResult);4module.exports = function (config) {5 config.set({6 });7};8{9 "scripts": {10 },11 "devDependencies": {12 },13 "dependencies": {14 }15}16{17 "scripts": {18 },19 "devDependencies": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var actualDryRunResult = require('stryker-parent').actualDryRunResult;2var options = { files: ['test.js'] };3actualDryRunResult(options).then(function (result) {4 console.log(result);5});6var dryRunResult = require('stryker-parent').dryRunResult;7var options = { files: ['test.js'] };8dryRunResult(options).then(function (result) {9 console.log(result);10});11var dryRun = require('stryker-parent').dryRun;12var options = { files: ['test.js'] };13dryRun(options).then(function (result) {14 console.log(result);15});16var mutationTest = require('stryker-parent').mutationTest;17var options = { files: ['test.js'] };18mutationTest(options).then(function (result) {19 console.log(result);20});21var mutationTestResult = require('stryker-parent').mutationTestResult;22var options = { files: ['test.js'] };23mutationTestResult(options).then(function (result) {24 console.log(result);25});26var mutationTestReport = require('stryker-parent').mutationTestReport;27var options = { files: ['test.js'] };28mutationTestReport(options).then(function (result) {29 console.log(result);30});31var mutationTestReportResult = require('stryker-parent').mutationTestReportResult;32var options = { files: ['test.js'] };33mutationTestReportResult(options).then(function (result) {34 console.log(result);35});36var mutationTestReportAll = require('stryker-parent').mutationTestReportAll;37var options = { files: ['test.js'] };38mutationTestReportAll(options).then(function (result) {39 console.log(result);40});

Full Screen

Using AI Code Generation

copy

Full Screen

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

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