How to use arrangeSut method in stryker-parent

Best JavaScript code snippet using stryker-parent

create-test-runner-factory.it.spec.ts

Source:create-test-runner-factory.it.spec.ts Github

copy

Full Screen

...45 }46 await loggingServer.dispose();47 rmSync(CounterTestRunner.COUNTER_FILE);48 });49 async function arrangeSut(name: string): Promise<void> {50 testInjector.options.testRunner = name;51 sut = createSut();52 await sut.init?.();53 }54 function actDryRun(timeout = 4000) {55 return sut.dryRun(factory.dryRunOptions({ timeout, coverageAnalysis: 'all' }));56 }57 function actMutantRun(options = factory.mutantRunOptions()) {58 return sut.mutantRun(options);59 }60 it('should pass along the coverage result from the test runner behind', async () => {61 await arrangeSut('coverage-reporting');62 const result = await actDryRun();63 assertions.expectCompleted(result);64 expect(result.mutantCoverage).deep.eq(factory.mutantCoverage({ static: { 1: 42 } }));65 });66 it('should pass along the run result', async () => {67 await arrangeSut('direct-resolved');68 const result = await actDryRun();69 expect(result.status).eq(DryRunStatus.Complete);70 });71 it('should try to report coverage from the global scope, even when the test runner behind does not', async () => {72 await arrangeSut('direct-resolved');73 const result = await actDryRun();74 assertions.expectCompleted(result);75 expect(result.mutantCoverage).eq('coverageObject');76 });77 it('should resolve in a timeout if the test runner never resolves', async () => {78 await arrangeSut('never-resolved');79 const result = await actDryRun(1000);80 expect(result.status).eq(DryRunStatus.Timeout);81 });82 it('should be able to recover from a timeout by creating a new child process', async () => {83 await arrangeSut('never-resolved');84 await actDryRun(1000); // first timeout85 const result = await actDryRun(1000);86 expect(result.status).eq(DryRunStatus.Timeout);87 });88 it('should convert any `Error` objects to string', async () => {89 await arrangeSut('errored');90 const result = await actDryRun(1000);91 assertions.expectErrored(result);92 expect(result.errorMessage).includes('SyntaxError: This is invalid syntax!').and.includes('at ErroredTestRunner.dryRun');93 });94 it('should run only after initialization, even when it is slow', async () => {95 await arrangeSut('slow-init-dispose');96 const result = await actDryRun(1000);97 assertions.expectCompleted(result);98 });99 it('should be able to run twice in quick succession', async () => {100 await arrangeSut('direct-resolved');101 const result = await actDryRun();102 assertions.expectCompleted(result);103 });104 it('should reject when `init` of test runner behind rejects', async () => {105 await expect(arrangeSut('reject-init')).rejectedWith('Init was rejected');106 });107 it('should still shutdown the child process, even when test runner dispose rejects', async () => {108 arrangeSut('errored');109 await sut.dispose?.();110 });111 it('should change the current working directory to the sandbox directory', async () => {112 await arrangeSut('verify-working-folder');113 const result = await actDryRun();114 assertions.expectCompleted(result);115 });116 it('should be able to recover from an async crash', async () => {117 // time-bomb will crash after 500 ms118 await arrangeSut('time-bomb');119 await sleep(550);120 const result = await actDryRun();121 assertions.expectCompleted(result);122 });123 it('should report if a crash happens twice', async () => {124 await arrangeSut('proximity-mine');125 const result = await actDryRun();126 assertions.expectErrored(result);127 expect(result.errorMessage).contains('Test runner crashed');128 });129 it('should handle asynchronously handled promise rejections from the underlying test runner', async () => {130 const logEvents = lastValueFrom(loggingServer.event$.pipe(toArray()));131 await arrangeSut('async-promise-rejection-handler');132 await actDryRun();133 await sut.dispose?.();134 alreadyDisposed = true;135 await loggingServer.dispose();136 const actualLogEvents = await logEvents;137 expect(138 actualLogEvents.find(139 (logEvent) =>140 log4js.levels.DEBUG.isEqualTo(logEvent.level) &&141 logEvent.data.toString().includes('UnhandledPromiseRejectionWarning: Unhandled promise rejection')142 )143 ).ok;144 });145 it('should restart the worker after it has exceeded the maxTestRunnerReuse', async () => {146 testInjector.options.maxTestRunnerReuse = 3;147 await arrangeSut('counter');148 await actMutantRun();149 expect(fs.readFileSync(CounterTestRunner.COUNTER_FILE, 'utf8')).to.equal('1');150 await actMutantRun();151 expect(fs.readFileSync(CounterTestRunner.COUNTER_FILE, 'utf8')).to.equal('2');152 await actMutantRun();153 expect(fs.readFileSync(CounterTestRunner.COUNTER_FILE, 'utf8')).to.equal('3');154 await actMutantRun();155 expect(fs.readFileSync(CounterTestRunner.COUNTER_FILE, 'utf8')).to.equal('1');156 });...

Full Screen

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