Best JavaScript code snippet using stryker-parent
child-process-proxy.it.spec.ts
Source:child-process-proxy.it.spec.ts
1import path from 'path';2import { LogLevel } from '@stryker-mutator/api/core';3import { Logger } from '@stryker-mutator/api/logging';4import { commonTokens } from '@stryker-mutator/api/plugin';5import { testInjector, LoggingServer } from '@stryker-mutator/test-helpers';6import { expect } from 'chai';7import log4js from 'log4js';8import { filter } from 'rxjs/operators';9import { Task } from '@stryker-mutator/util';10import { ChildProcessCrashedError } from '../../../src/child-proxy/child-process-crashed-error';11import { ChildProcessProxy } from '../../../src/child-proxy/child-process-proxy';12import { OutOfMemoryError } from '../../../src/child-proxy/out-of-memory-error';13import { currentLogMock } from '../../helpers/log-mock';14import { Mock } from '../../helpers/producers';15import { sleep } from '../../helpers/test-utils';16import { Echo } from './echo';17describe(ChildProcessProxy.name, () => {18 let sut: ChildProcessProxy<Echo>;19 let loggingServer: LoggingServer;20 let log: Mock<Logger>;21 const echoName = 'The Echo Server';22 const workingDir = '..';23 beforeEach(async () => {24 loggingServer = new LoggingServer();25 const port = await loggingServer.listen();26 const options = testInjector.injector.resolve(commonTokens.options);27 log = currentLogMock();28 sut = ChildProcessProxy.create(require.resolve('./echo'), { port, level: LogLevel.Debug }, options, { name: echoName }, workingDir, Echo, [29 '--no-warnings', // test if node args are forwarded with this setting, see https://nodejs.org/api/cli.html#cli_no_warnings30 '--max-old-space-size=32', // reduce the amount of time we have to wait on the OOM test31 ]);32 });33 afterEach(async () => {34 try {35 await sut.dispose();36 await loggingServer.dispose();37 } catch (error) {38 console.error(error);39 }40 });41 it('should be able to get direct result', async () => {42 const actual = await sut.proxy.say('hello');43 expect(actual).eq(`${echoName}: hello`);44 });45 it('should be able to get delayed result', async () => {46 const actual = await sut.proxy.sayDelayed('hello', 2);47 expect(actual).eq(`${echoName}: hello (2 ms)`);48 });49 it('should set the current working directory', async () => {50 const actual = await sut.proxy.cwd();51 expect(actual).eq(path.resolve(workingDir));52 });53 it('should use `execArgv` to start the child process', async () => {54 await sut.proxy.warning();55 expect(sut.stderr).not.includes('Foo warning');56 });57 it('should be able to receive a promise rejection', async () => {58 await expect(sut.proxy.reject('Foobar error')).rejectedWith('Foobar error');59 });60 it('should be able to receive public properties as promised', () => {61 return expect(sut.proxy.name()).eventually.eq(echoName);62 });63 it('should be able to log on debug when LogLevel.Debug is allowed', async () => {64 const logEventTask = new Task<log4js.LoggingEvent>();65 loggingServer.event$.pipe(filter((event) => event.categoryName === Echo.name)).subscribe(logEventTask.resolve.bind(logEventTask));66 sut.proxy.debug('test message');67 const logger = await logEventTask.promise;68 expect(logger.categoryName).eq(Echo.name);69 expect(logger.data).deep.eq(['test message']);70 });71 it('should not log on trace if LogLevel.Debug is allowed as min log level', async () => {72 const logEventTask = new Task<log4js.LoggingEvent>();73 loggingServer.event$.pipe(filter((event) => event.categoryName === Echo.name)).subscribe(logEventTask.resolve.bind(logEventTask));74 sut.proxy.trace('foo');75 sut.proxy.debug('bar');76 const logger = await logEventTask.promise;77 expect(logger.categoryName).eq(Echo.name);78 expect(logger.data).deep.eq(['bar']);79 expect(toLogLevel(logger.level)).eq(LogLevel.Debug);80 });81 it('should reject when the child process exits', () => {82 return expect(sut.proxy.exit(42)).rejectedWith(ChildProcessCrashedError);83 });84 it('should log stdout and stderr on warning when a child process crashed', async () => {85 await sut.proxy.stdout('stdout message');86 await sut.proxy.stderr('stderr message');87 // Give nodejs the chance to flush the stdout and stderr buffers88 await sleep(10);89 await expect(sut.proxy.exit(12)).rejected;90 const call = log.warn.getCall(0);91 expect(call.args[0]).matches(92 /Child process \[pid \d+\] exited unexpectedly with exit code 12 \(without signal\)\. Last part of stdout and stderr was/g93 );94 expect(call.args[0]).includes('stdout message');95 expect(call.args[0]).includes('stderr message');96 });97 it('should immediately reject any subsequent calls when the child process exits', async () => {98 await expect(sut.proxy.exit(1)).rejected;99 await expect(sut.proxy.say('something')).rejectedWith(ChildProcessCrashedError);100 });101 it('should throw an OutOfMemoryError if the process went out-of-memory', async () => {102 await expect(sut.proxy.memoryLeak()).rejectedWith(OutOfMemoryError);103 });104});105function toLogLevel(level: log4js.Level) {106 const levelName = (level as any).levelStr.toLowerCase();107 return [LogLevel.Debug, LogLevel.Error, LogLevel.Fatal, LogLevel.Information, LogLevel.Off, LogLevel.Trace, LogLevel.Warning].find(108 (logLevel) => logLevel === levelName109 );...
Using AI Code Generation
1const logEventTask = require('stryker-parent').logEventTask;2module.exports = function (grunt) {3 grunt.registerTask('log-event', logEventTask(grunt));4};5module.exports = function (grunt) {6 grunt.initConfig({7 logEvent: {8 options: {9 }10 }11 });12 grunt.loadNpmTasks('test');13 grunt.registerTask('default', ['log-event']);14};15{16 "scripts": {17 },18 "devDependencies": {19 }20}21module.exports = function (config) {22 config.set({23 });24};25{26 "data": {}27}
Using AI Code Generation
1var logEventTask = require('stryker-parent').logEventTask;2logEventTask('test', 'test', 'test');3var logEvent = require('stryker-parent').logEvent;4logEvent('test', 'test', 'test');5var logError = require('stryker-parent').logError;6logError('test', 'test', 'test');7var logEventTask = require('stryker-parent').logEventTask;8logEventTask('test', 'test', 'test');9var logEvent = require('stryker-parent').logEvent;10logEvent('test', 'test', 'test');11var logError = require('stryker-parent').logError;12logError('test', 'test', 'test');13var logEventTask = require('stryker-parent').logEventTask;14logEventTask('test', 'test', 'test');15var logEvent = require('stryker-parent').logEvent;16logEvent('test', 'test', 'test');17var logError = require('stryker-parent').logError;18logError('test', 'test', 'test');19var logEventTask = require('stryker-parent').logEventTask;20logEventTask('test', 'test', 'test');21var logEvent = require('stryker-parent').logEvent;22logEvent('test', 'test', 'test');23var logError = require('stryker-parent').logError;24logError('test', 'test', 'test');25var logEventTask = require('stryker-parent').logEventTask;
Using AI Code Generation
1var logEventTask = require('stryker-parent').logEventTask;2logEventTask('test', 'test message');3logEventTask('test', 'test message', {test:'test'});4logEventTask('test', 'test message', {test:'test'}, 'test');5logEventTask('test', 'test message', {test:'test'}, 'test', 'test');6logEventTask('test', 'test message', {test:'test'}, 'test', 'test', 'test');7logEventTask('test', 'test message', {test:'test'}, 'test', 'test', 'test', 'test');8logEventTask('test', 'test message', {test:'test'}, 'test', 'test', 'test', 'test', 'test');9logEventTask('test', 'test message', {test:'test'}, 'test', 'test', 'test', 'test', 'test', 'test');10logEventTask('test', 'test message', {test:'test'}, 'test', 'test', 'test', 'test', 'test', 'test', 'test');11logEventTask('test', 'test message', {test:'test'}, 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test');12logEventTask('test', 'test message', {test:'test'}, 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test');13logEventTask('test', 'test message', {test:'test'}, 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test');14logEventTask(
Using AI Code Generation
1const { logEventTask } = require('stryker-parent');2module.exports = function(config) {3 logEventTask(config, 'test');4};5module.exports = function(config) {6 config.set({7 babel: {8 },9 mochaOptions: {10 }11 });12};
Using AI Code Generation
1var stryker = require('stryker-parent');2var test = require('test');3var logEventTask = stryker.logEventTask;4var log = stryker.log;5var logEvent = stryker.logEvent;6var stryker = require('stryker-parent');7var test = require('test');8var logEventTask = stryker.logEventTask;9var log = stryker.log;10var logEvent = stryker.logEvent;11var stryker = require('stryker-parent');12var test = require('test');13var logEventTask = stryker.logEventTask;14var log = stryker.log;15var logEvent = stryker.logEvent;16var stryker = require('stryker-parent');17var test = require('test');18var logEventTask = stryker.logEventTask;19var log = stryker.log;20var logEvent = stryker.logEvent;21var stryker = require('stryker-parent');22var test = require('test');23var logEventTask = stryker.logEventTask;24var log = stryker.log;25var logEvent = stryker.logEvent;26var stryker = require('stryker-parent');27var test = require('test');28var logEventTask = stryker.logEventTask;29var log = stryker.log;30var logEvent = stryker.logEvent;31var stryker = require('stryker-parent');32var test = require('test');33var logEventTask = stryker.logEventTask;34var log = stryker.log;35var logEvent = stryker.logEvent;36var stryker = require('stryker-parent');37var test = require('test');38var logEventTask = stryker.logEventTask;39var log = stryker.log;40var logEvent = stryker.logEvent;41var stryker = require('stryker-parent');42var test = require('test');43var logEventTask = stryker.logEventTask;44var log = stryker.log;45var logEvent = stryker.logEvent;46var stryker = require('stryker-parent');47var test = require('test');48var logEventTask = stryker.logEventTask;49var log = stryker.log;50var logEvent = stryker.logEvent;51var stryker = require('stryker-parent');52var test = require('test');
Using AI Code Generation
1const {logEventTask} = require('@stryker-mutator/core');2logEventTask('my event');3const {logEventTask} = require('@stryker-mutator/core');4logEventTask('my event');5const {logEventTask} = require('@stryker-mutator/core');6logEventTask('my event');7const {logEventTask} = require('@stryker-mutator/core');8logEventTask('my event');9const {logEventTask} = require('@stryker-mutator/core');10logEventTask('my event');11const {logEventTask} = require('@stryker-mutator/core');12logEventTask('my event');13const {logEventTask} = require('@stryker-mutator/core');14logEventTask('my event');15const {logEventTask} = require('@stryker-mutator/core');16logEventTask('my event');17const {
Using AI Code Generation
1const strykerParent = require('stryker-parent');2const strykerEventRecorder = strykerParent.createEventRecorder();3strykerEventRecorder.logEventTask('taskName', 'taskDescription', 1);4const strykerParent = require('stryker-parent');5const strykerEventRecorder = strykerParent.createEventRecorder();6strykerEventRecorder.logEventTask('taskName', 'taskDescription', 1);7const strykerParent = require('stryker-parent');8const strykerEventRecorder = strykerParent.createEventRecorder();9strykerEventRecorder.logEventTask('taskName', 'taskDescription', 1);10const strykerParent = require('stryker-parent');11const strykerEventRecorder = strykerParent.createEventRecorder();12strykerEventRecorder.logEventTask('taskName', 'taskDescription', 1);13const strykerParent = require('stryker-parent');14const strykerEventRecorder = strykerParent.createEventRecorder();15strykerEventRecorder.logEventTask('taskName', 'taskDescription', 1);16const strykerParent = require('stryker-parent');17const strykerEventRecorder = strykerParent.createEventRecorder();18strykerEventRecorder.logEventTask('taskName', 'taskDescription', 1);19const strykerParent = require('stryker-parent');20const strykerEventRecorder = strykerParent.createEventRecorder();21strykerEventRecorder.logEventTask('taskName', 'taskDescription', 1);22const strykerParent = require('stryker-parent');23const strykerEventRecorder = strykerParent.createEventRecorder();24strykerEventRecorder.logEventTask('taskName', 'taskDescription', 1
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!!