Best JavaScript code snippet using stryker-parent
worker-thread-worker.spec.ts
Source:worker-thread-worker.spec.ts
...47 test('executeTask should create new worker thread, post dask-data and return emitted message', async () => {48 const workerMock = new AutoResponseWorkerMock(0);49 WorkerConstructorMockFn.mockImplementationOnce(() => workerMock);50 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');51 const result = await worker.executeTask({52 timeout: 3000,53 data: 'test'54 });55 expect(result).toEqual('Result: test');56 expect(WorkerConstructorMockFn).toHaveBeenCalledWith('worker_script_path');57 });58 test('executeTask should reject if worker emits an error', async () => {59 const workerMock = new AutoErrorWorkerMock(0);60 WorkerConstructorMockFn.mockImplementationOnce(() => workerMock);61 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');62 const resultPromise = worker.executeTask({63 timeout: 3000,64 data: 'test-data'65 });66 await expect(resultPromise).rejects.toThrowError('Error: test-data');67 });68 test('executeTask should reject if worker exits before emitting a message', async () => {69 const workerMock = new AutoExitWorkerMock(0);70 WorkerConstructorMockFn.mockImplementationOnce(() => workerMock);71 const worker = new WorkerThreadWorker<number, string, WorkerThreadTask<number>>('worker_script_path');72 const resultPromise = worker.executeTask({73 timeout: 3000,74 data: -175 });76 await expect(resultPromise).rejects.toThrowError('Worker terminated with code -1');77 });78 test('executeTask on a busy worker should reject', async () => {79 const workerMock = new TestWorkerMock();80 WorkerConstructorMockFn.mockImplementationOnce(() => workerMock);81 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');82 const resultPromise = worker.executeTask({83 timeout: 10000,84 data: 'test'85 });86 const busyResultPromise = worker.executeTask({87 timeout: 10000,88 data: 'test'89 });90 await expect(busyResultPromise).rejects.toThrowError('Worker busy. Cannot execute mutiple tasks in parallel!');91 workerMock.emit('message', 'Result!');92 const result = await resultPromise;93 expect(result).toEqual('Result!');94 });95 test('executeTask should timeout if worker does not repsond in the given time', async () => {96 const workerMock = new TestWorkerMock();97 WorkerConstructorMockFn.mockImplementationOnce(() => workerMock);98 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');99 const executionStart = Date.now();100 const resultPromise = worker.executeTask({101 timeout: 100,102 data: 'test'103 });104 await expect(resultPromise).rejects.toThrowError('Worker execution timed out after 100 ms');105 const duration = Date.now() - executionStart;106 expect(duration).toBeGreaterThanOrEqual(100);107 expect(duration).toBeLessThan(150);108 });109 test('error$ should emit an error if termination of timed out worker fails', async () => {110 const workerMock = new TestWorkerMock();111 WorkerConstructorMockFn.mockImplementationOnce(() => workerMock);112 jest.spyOn(workerMock, 'terminate').mockImplementationOnce(() => Promise.reject(new Error('TerminationError')));113 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');114 const errorEmitterPromise = firstValueFrom(worker.error$.pipe(take(2), bufferCount(2)));115 const resultPromise = worker.executeTask({116 timeout: 0,117 data: 'test'118 });119 await expect(resultPromise).rejects.toThrowError('Worker execution timed out after 0 ms');120 const emittedError = await errorEmitterPromise;121 expect(emittedError[0]).toMatchObject({ message: 'Worker execution timed out after 0 ms' });122 expect(emittedError[1]).toMatchObject({ message: 'Error while terminating worker: TerminationError' });123 });124 test('executeTask should reuse worker thread if previous execution succeeded', async () => {125 const workerMock = new AutoResponseWorkerMock(0);126 WorkerConstructorMockFn.mockImplementationOnce(() => workerMock);127 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');128 const result1 = await worker.executeTask({129 timeout: 3000,130 data: 'test1'131 });132 expect(result1).toEqual('Result: test1');133 const result2 = await worker.executeTask({134 timeout: 3000,135 data: 'test2'136 });137 expect(result2).toEqual('Result: test2');138 expect(WorkerConstructorMockFn).toHaveBeenCalledTimes(1);139 });140 test('executeTask should create new worker thread if previous failed', async () => {141 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoErrorWorkerMock(0));142 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');143 const task1Promise = worker.executeTask({144 timeout: 3000,145 data: 'SomeError'146 });147 await expect(task1Promise).rejects.toThrowError('Error: SomeError');148 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoResponseWorkerMock(0));149 const result = await worker.executeTask({150 timeout: 3000,151 data: 'test'152 });153 expect(result).toEqual('Result: test');154 expect(WorkerConstructorMockFn).toHaveBeenCalledTimes(2);155 });156 test('executeTask should create new worker thread if previous exited', async () => {157 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoExitWorkerMock(0));158 const worker = new WorkerThreadWorker<number, string, WorkerThreadTask<number>>('worker_script_path');159 const task1Promise = worker.executeTask({160 timeout: 3000,161 data: 0162 });163 await expect(task1Promise).rejects.toThrowError('Worker terminated with code 0');164 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoResponseWorkerMock(0));165 const result = await worker.executeTask({166 timeout: 3000,167 data: 1000168 });169 expect(result).toEqual('Result: 1000');170 expect(WorkerConstructorMockFn).toHaveBeenCalledTimes(2);171 });172 test('executeTask should create new worker thread if previous timed out', async () => {173 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoResponseWorkerMock(10));174 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');175 const task1Promise = worker.executeTask({176 timeout: 0,177 data: 'test1'178 });179 await expect(task1Promise).rejects.toThrowError('Worker execution timed out after 0 ms');180 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoResponseWorkerMock(0));181 const result = await worker.executeTask({182 timeout: 3000,183 data: 'test2'184 });185 expect(result).toEqual('Result: test2');186 expect(WorkerConstructorMockFn).toHaveBeenCalledTimes(2);187 });188 test('error$ should emit an error if worker fails', async () => {189 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoErrorWorkerMock(0));190 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');191 const errorEmitterPromise = firstValueFrom(worker.error$);192 const taskPromise = worker.executeTask({193 timeout: 3000,194 data: 'Some Error'195 });196 await expect(taskPromise).rejects.toThrowError('Error: Some Error');197 const emittedError = await errorEmitterPromise;198 expect(emittedError).toMatchObject({ message: 'Worker failed with error: Error: Some Error' });199 });200 test('error$ should emit an error if worker exits with statuscode 0', async () => {201 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoExitWorkerMock(0));202 const worker = new WorkerThreadWorker<number, string, WorkerThreadTask<number>>('worker_script_path');203 const errorEmitterPromise = firstValueFrom(worker.error$);204 const taskPromise = worker.executeTask({205 timeout: 3000,206 data: 0207 });208 await expect(taskPromise).rejects.toThrowError('Worker terminated with code 0');209 const emittedError = await errorEmitterPromise;210 expect(emittedError).toMatchObject({211 message: 'Worker terminated gracefully. This should not happen in a WorkerThreadWorker!'212 });213 });214 test('error$ should emit an error if worker exits with statuscode 0', async () => {215 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoExitWorkerMock(0));216 const worker = new WorkerThreadWorker<number, string, WorkerThreadTask<number>>('worker_script_path');217 const errorEmitterPromise = firstValueFrom(worker.error$);218 const taskPromise = worker.executeTask({219 timeout: 3000,220 data: 1221 });222 await expect(taskPromise).rejects.toThrowError('Worker terminated with code 1');223 const emittedError = await errorEmitterPromise;224 expect(emittedError).toMatchObject({ message: 'Worker terminated with exit code 1!' });225 });226 test('executeTask on a disposed worker should reject', async () => {227 const worker = new WorkerThreadWorker<number, string, WorkerThreadTask<number>>('worker_script_path');228 worker.dispose();229 const taskPromise = worker.executeTask({230 timeout: 3000,231 data: 1232 });233 await expect(taskPromise).rejects.toThrowError('Cannot get worker in a disposed WorkerThreadWorker!');234 });235 test('executeTask should create new worker if worker was terminated', async () => {236 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoResponseWorkerMock(0));237 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');238 const result1 = await worker.executeTask({239 timeout: 3000,240 data: 'test1'241 });242 expect(result1).toEqual('Result: test1');243 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoResponseWorkerMock(0));244 worker.terminateWorker();245 const result2 = await worker.executeTask({246 timeout: 3000,247 data: 'test2'248 });249 expect(result2).toEqual('Result: test2');250 expect(WorkerConstructorMockFn).toHaveBeenCalledTimes(2);251 });252 test('executeTask should create new worker if worker failed between task executions', async () => {253 const workerMock = new AutoResponseWorkerMock(0);254 WorkerConstructorMockFn.mockImplementationOnce(() => workerMock);255 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');256 const errorEmitterPromise = firstValueFrom(worker.error$);257 const result1 = await worker.executeTask({258 timeout: 3000,259 data: 'test1'260 });261 expect(result1).toEqual('Result: test1');262 workerMock.emit('error', new Error('Random Error'));263 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoResponseWorkerMock(0));264 const result2 = await worker.executeTask({265 timeout: 3000,266 data: 'test2'267 });268 expect(result2).toEqual('Result: test2');269 expect(WorkerConstructorMockFn).toHaveBeenCalledTimes(2);270 const emittedError = await errorEmitterPromise;271 expect(emittedError).toMatchObject({ message: 'Worker failed with error: Random Error' });272 });273 test('executeTask should create new worker if worker terminates between task executions', async () => {274 const workerMock = new AutoResponseWorkerMock(0);275 WorkerConstructorMockFn.mockImplementationOnce(() => workerMock);276 const worker = new WorkerThreadWorker<string, string, WorkerThreadTask<string>>('worker_script_path');277 const errorEmitterPromise = firstValueFrom(worker.error$);278 const result1 = await worker.executeTask({279 timeout: 3000,280 data: 'test1'281 });282 expect(result1).toEqual('Result: test1');283 workerMock.emit('exit', 10);284 WorkerConstructorMockFn.mockImplementationOnce(() => new AutoResponseWorkerMock(0));285 const result2 = await worker.executeTask({286 timeout: 3000,287 data: 'test2'288 });289 expect(result2).toEqual('Result: test2');290 expect(WorkerConstructorMockFn).toHaveBeenCalledTimes(2);291 const emittedError = await errorEmitterPromise;292 expect(emittedError).toMatchObject({ message: 'Worker terminated with exit code 10!' });293 });...
dynamic-worker-pool.spec.ts
Source:dynamic-worker-pool.spec.ts
1import { bufferCount, firstValueFrom } from 'rxjs';2import { DynamicWorkerPool } from './dynamic-worker-pool';3class TestWorker {4 public async executeTask(t: string): Promise<string> {5 return `result: ${t}`;6 }7 public async dispose(): Promise<void> {8 // noting to do9 }10}11const testWorkerInstance = new TestWorker();12const workerFactory = { createWorker: (): TestWorker => testWorkerInstance };13describe('DynamicWorkerPool', () => {14 beforeEach(() => {15 jest.clearAllMocks();16 });17 test('size of new pool should be 0', () => {18 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 0, 5, 0);19 expect(testPool.size).toEqual(0);20 });21 test('execute task should aquire new workers and execute tasks on them', async () => {22 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 0, 2, 0);23 const workerDisposeSpy = jest.spyOn(testWorkerInstance, 'dispose');24 const createWorkerSpy = jest.spyOn(workerFactory, 'createWorker');25 expect(testPool.size).toEqual(0);26 const resultPromises = Promise.all([testPool.executeTask('1'), testPool.executeTask('2')]);27 expect(testPool.size).toEqual(2);28 const results = await resultPromises;29 expect(results).toEqual(['result: 1', 'result: 2']);30 expect(testPool.size).toEqual(0);31 expect(createWorkerSpy).toHaveBeenCalledTimes(2);32 expect(workerDisposeSpy).toHaveBeenCalledTimes(2);33 });34 test('worker pool should hould minSize workers', async () => {35 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 3, 5, 0);36 const workerDisposeSpy = jest.spyOn(testWorkerInstance, 'dispose');37 const createWorkerSpy = jest.spyOn(workerFactory, 'createWorker');38 expect(testPool.size).toEqual(0);39 const resultPromises = Promise.all([40 testPool.executeTask('1'),41 testPool.executeTask('2'),42 testPool.executeTask('3'),43 testPool.executeTask('4'),44 testPool.executeTask('5')45 ]);46 expect(testPool.size).toEqual(5);47 await resultPromises;48 expect(testPool.size).toEqual(3);49 expect(createWorkerSpy).toHaveBeenCalledTimes(5);50 expect(workerDisposeSpy).toHaveBeenCalledTimes(2);51 });52 test('executeTask should reject if worker pool max size is reached', async () => {53 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 0, 1, 0);54 const workerDisposeSpy = jest.spyOn(testWorkerInstance, 'dispose');55 const createWorkerSpy = jest.spyOn(workerFactory, 'createWorker');56 expect(testPool.size).toEqual(0);57 const resultPromises = Promise.all([testPool.executeTask('1'), testPool.executeTask('2')]);58 expect(testPool.size).toEqual(1);59 await expect(resultPromises).rejects.toThrowError('No free workers available in worker pool of max-size 1');60 expect(testPool.size).toEqual(0);61 expect(createWorkerSpy).toHaveBeenCalledTimes(1);62 expect(workerDisposeSpy).toHaveBeenCalledTimes(1);63 });64 test('worker pool should re-use existing workers in pool', async () => {65 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 1, 1, 0);66 const workerDisposeSpy = jest.spyOn(testWorkerInstance, 'dispose');67 const createWorkerSpy = jest.spyOn(workerFactory, 'createWorker');68 expect(testPool.size).toEqual(0);69 await testPool.executeTask('1');70 expect(testPool.size).toEqual(1);71 await testPool.executeTask('2');72 expect(testPool.size).toEqual(1);73 expect(createWorkerSpy).toHaveBeenCalledTimes(1);74 expect(workerDisposeSpy).toHaveBeenCalledTimes(0);75 });76 test('worker pool should emit an error on error$ if worker disposal fails', async () => {77 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 0, 1, 0);78 jest.spyOn(testWorkerInstance, 'dispose').mockImplementationOnce(async () => {79 throw new Error('DisposeError');80 });81 const errorPromise = firstValueFrom(testPool.error$);82 await testPool.executeTask('1');83 await expect(errorPromise).resolves.toMatchObject({84 message: 'Error while disposing worker-pool worker: DisposeError'85 });86 });87 test('executeTask on a stopped DynamicWorkerPool should reject', async () => {88 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);89 testPool.stop();90 await expect(testPool.executeTask('1')).rejects.toThrowError('Cannot aquire worker from stopped worker pool!');91 });92 test('stop should terminate all current workers', async () => {93 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);94 const workerDisposeSpy = jest.spyOn(testWorkerInstance, 'dispose');95 await Promise.all([96 testPool.executeTask('1'),97 testPool.executeTask('2'),98 testPool.executeTask('3'),99 testPool.executeTask('4'),100 testPool.executeTask('5')101 ]);102 await testPool.stop();103 expect(testPool.size).toEqual(0);104 expect(workerDisposeSpy).toHaveBeenCalledTimes(5);105 });106 test('busyWorkers$ should emit number of workers in use', async () => {107 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);108 const busyWorkersHistoryPromise = firstValueFrom(testPool.busyWorkers$.pipe(bufferCount(13)));109 await Promise.all([110 testPool.executeTask('1'),111 testPool.executeTask('2'),112 testPool.executeTask('3'),113 testPool.executeTask('4'),114 testPool.executeTask('5')115 ]);116 await testPool.executeTask('6');117 expect(await busyWorkersHistoryPromise).toEqual([0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 0]);118 });119 test('idleWorkers$ should emit number of idle workers', async () => {120 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);121 const idleWorkersHistoryPromise = firstValueFrom(testPool.idleWorkers$.pipe(bufferCount(5)));122 await Promise.all([123 testPool.executeTask('1'),124 testPool.executeTask('2'),125 testPool.executeTask('3'),126 testPool.executeTask('4'),127 testPool.executeTask('5')128 ]);129 await testPool.executeTask('6');130 expect(await idleWorkersHistoryPromise).toEqual([0, 1, 2, 1, 2]);131 });132 test('availableWorkers$ should emit number of available workers', async () => {133 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);134 const availableWorkersHistoryPromise = firstValueFrom(testPool.availableWorkers$.pipe(bufferCount(13)));135 await Promise.all([136 testPool.executeTask('1'),137 testPool.executeTask('2'),138 testPool.executeTask('3'),139 testPool.executeTask('4'),140 testPool.executeTask('5')141 ]);142 await testPool.executeTask('6');143 expect(await availableWorkersHistoryPromise).toEqual([5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 5]);144 });145 test('availableWorkers$ should emit 0 for a stopped pool', async () => {146 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);147 const availableWorkersHistoryPromise = firstValueFrom(testPool.availableWorkers$.pipe(bufferCount(4)));148 await testPool.executeTask('1');149 await testPool.stop();150 expect(await availableWorkersHistoryPromise).toEqual([5, 4, 5, 0]);151 });152 test('availableWorkers should return 0 for a stopped pool', async () => {153 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);154 await testPool.stop();155 expect(testPool.availableWorkers).toEqual(0);156 });157 test('availableWorkers should return number of possible free workers', async () => {158 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);159 expect(testPool.availableWorkers).toEqual(5);160 const taskResultPromise = testPool.executeTask('1');161 expect(testPool.availableWorkers).toEqual(4);162 await taskResultPromise;163 expect(testPool.availableWorkers).toEqual(5);164 });165 test('idleWorkers should return 0 for a stopped pool', async () => {166 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);167 await testPool.stop();168 expect(testPool.idleWorkers).toEqual(0);169 });170 test('idleWorkers should return the number of created workers in idle state', async () => {171 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);172 expect(testPool.idleWorkers).toEqual(0);173 const taskResultPromise = testPool.executeTask('1');174 expect(testPool.idleWorkers).toEqual(0);175 await taskResultPromise;176 expect(testPool.idleWorkers).toEqual(1);177 });178 test('busyWorkers should return 0 for a stopped pool', async () => {179 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);180 await testPool.stop();181 expect(testPool.busyWorkers).toEqual(0);182 });183 test('busyWorkers should return the number of working workers', async () => {184 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 0);185 expect(testPool.busyWorkers).toEqual(0);186 const taskResultPromise = testPool.executeTask('1');187 expect(testPool.busyWorkers).toEqual(1);188 await taskResultPromise;189 expect(testPool.busyWorkers).toEqual(0);190 });191 test('DynamicWorkerPool with idleTimeout should keep idle workers for specified time', async () => {192 const testPool = new DynamicWorkerPool<string, string, TestWorker>(workerFactory, 2, 5, 100);193 const workerDisposeSpy = jest.spyOn(testWorkerInstance, 'dispose');194 await Promise.all([195 testPool.executeTask('1'),196 testPool.executeTask('2'),197 testPool.executeTask('3'),198 testPool.executeTask('4'),199 testPool.executeTask('5')200 ]);201 await new Promise((resolve) => setTimeout(resolve, 10));202 expect(workerDisposeSpy).toHaveBeenCalledTimes(0);203 expect(testPool.size).toEqual(5);204 await new Promise((resolve) => setTimeout(resolve, 100));205 expect(testPool.size).toEqual(2);206 expect(workerDisposeSpy).toHaveBeenCalledTimes(3);207 await testPool.stop();208 expect(testPool.size).toEqual(0);209 expect(workerDisposeSpy).toHaveBeenCalledTimes(5);210 });...
int-decisions.test.js
Source:int-decisions.test.js
...33 assert(contractInstance);34 // console.log(util.inspect(model, false, null, true));35 });36 it('int ==: start, A, B, [!D], C, [!E], F, end', async () => {37 await enzian.executeTask(contractInstance, model.idByName('start'), account0);38 await enzian.executeTask(contractInstance, model.idByName('A'), account0);39 try {40 await enzian.executeTask(contractInstance, model.idByName('B'), account0);41 assert(false);42 } catch(error)43 {44 assert(error);45 }46 enzian.updateProcessVariable(contractInstance, 'i', 5, account0);47 await enzian.executeTask(contractInstance, model.idByName('B'), account0);48 try {49 await enzian.executeTask(contractInstance, model.idByName('D'), account0);50 assert(false);51 } catch(error)52 {53 assert(error);54 }55 enzian.updateProcessVariable(contractInstance, 'i', 6, account0);56 try {57 await enzian.executeTask(contractInstance, model.idByName('D'), account0);58 assert(false);59 } catch(error)60 {61 // DO NOT REPEAT TASKS!!!62 assert(error);63 }64 await enzian.executeTask(contractInstance, model.idByName('C'), account0);65 try {66 await enzian.executeTask(contractInstance, model.idByName('E'), account0);67 assert(false);68 } catch(error)69 {70 // DO NOT REPEAT TASKS!!!71 assert(error);72 }73 await enzian.executeTask(contractInstance, model.idByName('F'), account0);74 await enzian.executeTask(contractInstance, model.idByName('end'), account0);75 // enzian.executeTask(contractInstance, model.idByName('start'), account0);76 // enzian.executeTask(contractInstance, model.idByName('start'), account0);77 // enzian.executeTask(contractInstance, model.idByName('start'), account0);78 let eventlog = await enzian.eventlog(contractInstance);79 console.log(eventlog);80 // console.log(util.inspect(model, false, null, true));81 });82 it('int >: start, A, B, [!D], C, [!E], F, end', async () => {83 await enzian.executeTask(contractInstance, model.idByName('start'), account0);84 await enzian.executeTask(contractInstance, model.idByName('A'), account0);85 try {86 await enzian.executeTask(contractInstance, model.idByName('B'), account0);87 assert(false);88 } catch(error)89 {90 assert(error);91 }92 enzian.updateProcessVariable(contractInstance, 'i', 5, account0);93 await enzian.executeTask(contractInstance, model.idByName('B'), account0);94 try {95 await enzian.executeTask(contractInstance, model.idByName('D'), account0);96 assert(false);97 } catch(error)98 {99 assert(error);100 }101 enzian.updateProcessVariable(contractInstance, 'i', 6, account0);102 try {103 await enzian.executeTask(contractInstance, model.idByName('D'), account0);104 assert(false);105 } catch(error)106 {107 // DO NOT REPEAT TASKS!!!108 assert(error);109 }110 await enzian.executeTask(contractInstance, model.idByName('C'), account0);111 try {112 await enzian.executeTask(contractInstance, model.idByName('E'), account0);113 assert(false);114 } catch(error)115 {116 // DO NOT REPEAT TASKS!!!117 assert(error);118 }119 await enzian.executeTask(contractInstance, model.idByName('F'), account0);120 await enzian.executeTask(contractInstance, model.idByName('end'), account0);121 // enzian.executeTask(contractInstance, model.idByName('start'), account0);122 // enzian.executeTask(contractInstance, model.idByName('start'), account0);123 // enzian.executeTask(contractInstance, model.idByName('start'), account0);124 let eventlog = await enzian.eventlog(contractInstance);125 console.log(eventlog);126 // console.log(util.inspect(model, false, null, true));127 });128 it('greater', async() => {129 await enzian.executeTask(contractInstance, model.idByName('start'), account0);130 await enzian.executeTask(contractInstance, model.idByName('A'), account0);131 try {132 await enzian.executeTask(contractInstance, model.idByName('B'), account0);133 assert(false);134 } catch(error)135 {136 assert(error);137 console.log("B1: i == 0", error)138 }139 enzian.updateProcessVariable(contractInstance, 'i', 6, account0);140 try {141 await enzian.executeTask(contractInstance, model.idByName('D'), account0);142 assert(false);143 } catch(error)144 {145 console.log("D. i==6", error);146 assert(error);147 }148 enzian.updateProcessVariable(contractInstance, 'i', 7, account0);149 await enzian.executeTask(contractInstance, model.idByName('D'), account0);150 enzian.updateProcessVariable(contractInstance, 'i', 5, account0);151 try {152 await enzian.executeTask(contractInstance, model.idByName('B'), account0);153 assert(false);154 } catch(error)155 {156 console.log("B2. i==5", error);157 assert(error);158 }159 let eventlog = await enzian.eventlog(contractInstance);160 console.log(eventlog);161 });...
Using AI Code Generation
1var parent = require('stryker-parent');2var stryker = require('stryker');3var Stryker = stryker.Stryker;4var StrykerCli = stryker.StrykerCli;5var strykerConfig = {6};7var strykerOptions = {8};9parent.executeTask(Stryker, StrykerCli, strykerConfig, strykerOptions);10{11 "scripts": {12 },13 "devDependencies": {14 },15 "dependencies": {16 }17}18var parent = require('stryker-parent');19var stryker = require('stryker');20var Stryker = stryker.Stryker;21var StrykerCli = stryker.StrykerCli;22var strykerConfig = {23};24var strykerOptions = {25};26var stryker = new Stryker(strykerConfig, strykerOptions);
Using AI Code Generation
1var executeTask = require('stryker-parent').executeTask;2executeTask('test', 'node_modules/.bin/jasmine');3var executeTask = require('stryker-parent').executeTask;4executeTask('test', 'node_modules/.bin/jasmine');5var executeTask = require('stryker-parent').executeTask;6executeTask('test', 'node_modules/.bin/jasmine');7var executeTask = require('stryker-parent').executeTask;8executeTask('test', 'node_modules/.bin/jasmine');9var executeTask = require('stryker-parent').executeTask;10executeTask('test', 'node_modules/.bin/jasmine');11var executeTask = require('stryker-parent').executeTask;12executeTask('test', 'node_modules/.bin/jasmine');13var executeTask = require('stryker-parent').executeTask;14executeTask('test', 'node_modules/.bin/jasmine');15var executeTask = require('stryker-parent').executeTask;16executeTask('test', 'node_modules/.bin/jasmine');17var executeTask = require('stryker-parent').executeTask;18executeTask('test', 'node_modules/.bin/jasmine');19var executeTask = require('stryker-parent').executeTask;20executeTask('test', 'node_modules/.bin/jasmine');21var executeTask = require('stryker-parent').executeTask;22executeTask('test', 'node_modules/.bin/jasmine');
Using AI Code Generation
1const stryker = require('stryker-parent');2stryker.executeTask('test', { /* task options */ });3const stryker = require('stryker');4stryker.executeTask('test', { /* task options */ });5const stryker = require('stryker-cli');6stryker.executeTask('test', { /* task options */ });7const stryker = require('stryker-api');8stryker.executeTask('test', { /* task options */ });9const stryker = require('stryker');10stryker.executeTask('test', { /* task options */ });11const stryker = require('stryker');12stryker.executeTask('test', { /* task options */ });13const stryker = require('stryker');14stryker.executeTask('test', { /* task options */ });15const stryker = require('stryker');16stryker.executeTask('test', { /* task options */ });17const stryker = require('stryker');18stryker.executeTask('test', { /* task options */ });19const stryker = require('stryker');20stryker.executeTask('test', { /* task options */ });21const stryker = require('stryker');22stryker.executeTask('test', { /* task options */ });23const stryker = require('stryker');24stryker.executeTask('test', { /* task options */ });
Using AI Code Generation
1const executeTask = require('stryker-parent').executeTask;2executeTask('mocha');3{4 "scripts": {5 }6}
Using AI Code Generation
1var stryker = require('stryker-parent');2var path = require('path');3var dir = path.resolve(__dirname, 'src');4 path.resolve(dir, 'app.js'),5 path.resolve(dir, 'main.js')6];7var config = {8};9var reporter = {10 onAllMutantsTested: function (results) {11 console.log(results);12 }13};14stryker.runMutationTest(config, reporter);15{ killed: 0, survived: 0, timeout: 0, noCoverage: 0, runtimeErrors: 0, compileErrors: 0, totalDetected: 0, totalUndetected: 0, totalMutants: 0, totalCovered: 0, mutationScore: 0, mutationScoreBasedOnCoveredCode: 0, files: { 'src/app.js': { language: 'javascript', mutants: [], source: 'var app = angular.module(\'app\', []);\r16app.controller(\'MainController\', function ($scope) {\r17 $scope.title = \'Hello World\';\r18});\r19', path: 'src/app.js', mutated: false, included: true }, 'src/main.js': { language: 'javascript', mutants: [], source: 'var app = angular.module(\'app\', []);\r20app.controller(\'MainController\', function ($scope) {\r21 $scope.title = \'Hello World\';\r22});\r23', path: 'src/main.js', mutated: false, included: true } } }
Using AI Code Generation
1import { executeTask } from 'stryker-parent'2executeTask('stryker', ['run', '--files', 'src/index.js', '--testRunner', 'jest'])3module.exports = function(config) {4 config.set({5 jest: {6 config: require('./jest.config.js'),7 }8 })9}10module.exports = {11}12{13 "scripts": {14 },15 "dependencies": {16 }17}
Using AI Code Generation
1var tl = require('vsts-task-lib');2var trm = require('vsts-task-lib/toolrunner');3var path = require('path');4var fs = require('fs');5var connectedServiceName = tl.getInput('ConnectedServiceName', true);6var scriptLocation = tl.getInput('ScriptLocation', true);7var scriptPath = tl.getPathInput('ScriptPath', true, true);8var scriptArguments = tl.getInput('ScriptArguments', false);9var azurePowerShellScriptLocation = tl.getInput('AzurePowerShellScriptLocation', true);10var azurePowerShellScriptPath = tl.getPathInput('AzurePowerShellScriptPath', true, true);11var azurePowerShellScriptArguments = tl.getInput('AzurePowerShellScriptArguments', false);12var azurePowerShellScriptVersion = tl.getInput('AzurePowerShellScriptVersion', false);13var azurePowerShellCustomVersion = tl.getInput('AzurePowerShellCustomVersion', false);14var serviceEndpoint = tl.getEndpointAuthorization(connectedServiceName, true);15var serviceEndpointUrl = tl.getEndpointUrl(connectedServiceName, true);16var azureCliLocation = tl.getVariable('Agent.ToolsDirectory');17var azureCli = path.join(azureCliLocation, 'azurecli', 'bin', 'azure.cmd');18var psLocation = tl.getVariable('Agent.ToolsDirectory');19var ps = path.join(psLocation, 'powershell', '6', 'pwsh');20var azurePsLocation = tl.getVariable('Agent.ToolsDirectory');21var azurePs = path.join(azurePsLocation,
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!