How to use fullWorkingDir method in stryker-parent

Best JavaScript code snippet using stryker-parent

child-process-worker.spec.ts

Source:child-process-worker.spec.ts Github

copy

Full Screen

1import path from 'path';2import { LogLevel } from '@stryker-mutator/api/core';3import { Logger } from '@stryker-mutator/api/logging';4import { factory, testInjector } from '@stryker-mutator/test-helpers';5import { expect } from 'chai';6import sinon from 'sinon';7import { ChildProcessProxyWorker } from '../../../src/child-proxy/child-process-proxy-worker';8import {9 CallMessage,10 InitMessage,11 ParentMessage,12 ParentMessageKind,13 WorkerMessage,14 WorkerMessageKind,15 WorkResult,16} from '../../../src/child-proxy/message-protocol';17import * as di from '../../../src/di';18import { LogConfigurator, LoggingClientContext } from '../../../src/logging';19import { serialize } from '../../../src/utils/string-utils';20import { currentLogMock } from '../../helpers/log-mock';21import { Mock } from '../../helpers/producers';22import { HelloClass } from './hello-class';23const LOGGING_CONTEXT: LoggingClientContext = Object.freeze({ port: 4200, level: LogLevel.Fatal });24describe(ChildProcessProxyWorker.name, () => {25 let processOnStub: sinon.SinonStub;26 let processSendStub: sinon.SinonStub;27 let processListenersStub: sinon.SinonStub;28 let configureChildProcessStub: sinon.SinonStub;29 let processRemoveListenerStub: sinon.SinonStub;30 let processChdirStub: sinon.SinonStub;31 let logMock: Mock<Logger>;32 let originalProcessSend: typeof process.send;33 let processes: NodeJS.MessageListener[];34 const workingDir = 'working dir';35 beforeEach(() => {36 processes = [];37 logMock = currentLogMock();38 processOnStub = sinon.stub(process, 'on');39 processListenersStub = sinon.stub(process, 'listeners');40 processListenersStub.returns(processes);41 processRemoveListenerStub = sinon.stub(process, 'removeListener');42 processSendStub = sinon.stub();43 // process.send is normally undefined44 originalProcessSend = process.send;45 process.send = processSendStub;46 processChdirStub = sinon.stub(process, 'chdir');47 configureChildProcessStub = sinon.stub(LogConfigurator, 'configureChildProcess');48 sinon.stub(di, 'buildChildProcessInjector').returns(testInjector.injector);49 });50 afterEach(() => {51 process.send = originalProcessSend;52 });53 it('should listen to parent process', () => {54 new ChildProcessProxyWorker();55 expect(processOnStub).calledWith('message');56 });57 describe('after init message', () => {58 let sut: ChildProcessProxyWorker;59 let initMessage: InitMessage;60 beforeEach(() => {61 sut = new ChildProcessProxyWorker();62 const options = factory.strykerOptions();63 initMessage = {64 additionalInjectableValues: { name: 'FooBarName' },65 kind: WorkerMessageKind.Init,66 loggingContext: LOGGING_CONTEXT,67 options,68 requireName: HelloClass.name,69 requirePath: require.resolve('./hello-class'),70 workingDirectory: workingDir,71 };72 });73 it('should create the correct real instance', () => {74 processOnMessage(initMessage);75 expect(sut.realSubject).instanceOf(HelloClass);76 const actual = sut.realSubject as HelloClass;77 expect(actual.name).eq('FooBarName');78 });79 it('should change the current working directory', () => {80 processOnMessage(initMessage);81 const fullWorkingDir = path.resolve(workingDir);82 expect(logMock.debug).calledWith(`Changing current working directory for this process to ${fullWorkingDir}`);83 expect(processChdirStub).calledWith(fullWorkingDir);84 });85 it("should not change the current working directory if it didn't change", () => {86 initMessage.workingDirectory = process.cwd();87 processOnMessage(initMessage);88 expect(logMock.debug).not.called;89 expect(processChdirStub).not.called;90 });91 it('should send "init_done"', async () => {92 processOnMessage(initMessage);93 const expectedWorkerResponse: ParentMessage = { kind: ParentMessageKind.Initialized };94 await tick(); // make sure promise is resolved95 expect(processSendStub).calledWith(serialize(expectedWorkerResponse));96 });97 it('should remove any additional listeners', async () => {98 // Arrange99 function noop() {100 //noop101 }102 processes.push(noop);103 // Act104 processOnMessage(initMessage);105 await tick(); // make sure promise is resolved106 // Assert107 expect(processRemoveListenerStub).calledWith('message', noop);108 });109 it('should set global log level', () => {110 processOnStub.callArgWith(1, serialize(initMessage));111 expect(configureChildProcessStub).calledWith(LOGGING_CONTEXT);112 });113 it('should handle unhandledRejection events', () => {114 processOnMessage(initMessage);115 const error = new Error('foobar');116 processOnStub.withArgs('unhandledRejection').callArgWith(1, error);117 expect(logMock.debug).calledWith(`UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ${error}`);118 });119 it('should handle rejectionHandled events', () => {120 processOnMessage(initMessage);121 processOnStub.withArgs('rejectionHandled').callArgWith(1);122 expect(logMock.debug).calledWith('PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 0)');123 });124 describe('on worker message', () => {125 async function actAndAssert(workerMessage: CallMessage, expectedResult: WorkResult) {126 // Act127 processOnMessage(initMessage);128 processOnMessage(workerMessage);129 await tick();130 // Assert131 expect(processSendStub).calledWith(serialize(expectedResult));132 }133 async function actAndAssertRejection(workerMessage: CallMessage, expectedError: string) {134 // Act135 processOnMessage(initMessage);136 processOnMessage(workerMessage);137 await tick();138 // Assert139 expect(processSendStub).calledWithMatch(`"correlationId":${workerMessage.correlationId.toString()}`);140 expect(processSendStub).calledWithMatch(`"kind":${ParentMessageKind.Rejection.toString()}`);141 expect(processSendStub).calledWithMatch(`"error":"Error: ${expectedError}`);142 }143 it('should send the result', async () => {144 // Arrange145 const workerMessage: WorkerMessage = {146 args: [],147 correlationId: 32,148 kind: WorkerMessageKind.Call,149 methodName: 'sayHello',150 };151 const expectedResult: WorkResult = {152 correlationId: 32,153 kind: ParentMessageKind.Result,154 result: 'hello from FooBarName',155 };156 await actAndAssert(workerMessage, expectedResult);157 });158 it('should send a rejection', async () => {159 // Arrange160 const workerMessage: WorkerMessage = {161 args: [],162 correlationId: 32,163 kind: WorkerMessageKind.Call,164 methodName: 'reject',165 };166 await actAndAssertRejection(workerMessage, 'Rejected');167 });168 it('should send a thrown synchronous error as rejection', async () => {169 // Arrange170 const workerMessage: WorkerMessage = {171 args: ['foo bar'],172 correlationId: 32,173 kind: WorkerMessageKind.Call,174 methodName: 'throw',175 };176 await actAndAssertRejection(workerMessage, 'foo bar');177 });178 it('should use correct arguments', async () => {179 // Arrange180 const workerMessage: WorkerMessage = {181 args: ['foo', 'bar', 'chair'],182 correlationId: 32,183 kind: WorkerMessageKind.Call,184 methodName: 'say',185 };186 const expectedResult: WorkResult = {187 correlationId: 32,188 kind: ParentMessageKind.Result,189 result: 'hello foo and bar and chair',190 };191 await actAndAssert(workerMessage, expectedResult);192 });193 it('should work with promises from real class', async () => {194 // Arrange195 const workerMessage: WorkerMessage = {196 args: [],197 correlationId: 32,198 kind: WorkerMessageKind.Call,199 methodName: 'sayDelayed',200 };201 const expectedResult: WorkResult = {202 correlationId: 32,203 kind: ParentMessageKind.Result,204 result: 'delayed hello from FooBarName',205 };206 await actAndAssert(workerMessage, expectedResult);207 });208 });209 });210 function processOnMessage(message: WorkerMessage) {211 processOnStub.withArgs('message').callArgWith(1, [serialize(message)]);212 }213});214function tick() {215 return new Promise((res) => setTimeout(res, 0));...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var fullWorkingDir = require('stryker-parent').fullWorkingDir;2var strykerConfig = {3 fullWorkingDir('src/**/*.js'),4 fullWorkingDir('test/**/*.js')5 fullWorkingDir('src/**/*.js')6 karma: {7 configFile: fullWorkingDir('karma.conf.js'),8 project: {9 basePath: fullWorkingDir()10 }11 }12};13module.exports = function(config) {14 config.set(strykerConfig);15};16module.exports = require('./test.js');17module.exports = function(config) {18 config.set({

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const { fullWorkingDir } = require('stryker-parent');3module.exports = function(config) {4 config.set({5 { pattern: fullWorkingDir('test.js'), included: true, mutated: false }6 });7};8const path = require('path');9const { fullWorkingDir } = require('stryker-parent');10module.exports = function(config) {11 config.set({12 { pattern: fullWorkingDir('test.js'), included: true, mutated: false }13 });14};15const path = require('path');16const { fullParentDir } = require('stryker-parent');17module.exports = function(config) {18 config.set({19 { pattern: fullParentDir('test.js'), included: true, mutated: false }20 });21};22const path = require('path');23const { fullParentDir } = require('stryker-parent');24module.exports = function(config) {25 config.set({

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const fullWorkingDir = strykerParent.fullWorkingDir;3console.log(fullWorkingDir());4const strykerParent = require('stryker-parent');5const fullWorkingDir = strykerParent.fullWorkingDir;6console.log(fullWorkingDir());

Full Screen

Using AI Code Generation

copy

Full Screen

1var path = require('path');2var fullWorkingDir = require('stryker-parent').fullWorkingDir;3var fullWorkingDir = fullWorkingDir(path.resolve(__dirname, 'stryker.conf.js'));4console.log(fullWorkingDir);5module.exports = function (config) {6 config.set({7 });8};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { fullWorkingDir } = require("stryker-parent/paths");2console.log(fullWorkingDir("some/relative/path"));3const { fullWorkingDir } = require("stryker-parent/paths");4console.log(fullWorkingDir("another/relative/path"));5const { fullWorkingDir } = require("stryker-parent/paths");6console.log(fullWorkingDir("yet/another/relative/path"));7const { fullWorkingDir } = require("stryker-parent/paths");8console.log(fullWorkingDir("one/more/relative/path"));9const { fullWorkingDir } = require("stryker-parent/paths");10console.log(fullWorkingDir("and/one/more/relative/path"));11const { fullWorkingDir } = require("stryker-parent/paths");12console.log(fullWorkingDir("and/one/more/relative/path"));13const { fullWorkingDir } = require("stryker-parent/paths");14console.log(fullWorkingDir("and/one/more/relative/path"));15const { fullWorkingDir } = require("stryker-parent/paths");16console.log(fullWorkingDir("and/one/more/relative/path"));17const { fullWorkingDir } = require("stryker-parent/paths");18console.log(fullWorkingDir("and/one/more/relative/path"));19const { fullWorkingDir } = require("stryker-parent/paths");20console.log(fullWorking

Full Screen

Using AI Code Generation

copy

Full Screen

1const { fullWorkingDir } = require('stryker-parent');2console.log(fullWorkingDir('/foo/bar'));3const { fullWorkingDir } = require('stryker-parent');4module.exports = function(config) {5 config.set({6 mutate: [fullWorkingDir('src/**/*.js')],7 });8};9"scripts": {10}

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2var path = require('path');3var fullWorkingDir = strykerParent.fullWorkingDir;4var pathToUse = path.join(fullWorkingDir, 'someDir');5console.log(pathToUse);6var strykerParent = require('stryker-parent');7var path = require('path');8var fullWorkingDir = strykerParent.fullWorkingDir;9var pathToUse = path.join(fullWorkingDir, 'someDir');10console.log(pathToUse);11var strykerParent = require('stryker-parent');12var path = require('path');13var fullWorkingDir = strykerParent.fullWorkingDir;14var pathToUse = path.join(fullWorkingDir, 'someDir');15console.log(pathToUse);16var strykerParent = require('stryker-parent');17var path = require('path');18var fullWorkingDir = strykerParent.fullWorkingDir;19var pathToUse = path.join(fullWorkingDir, 'someDir');20console.log(pathToUse);21var strykerParent = require('stryker-parent');22var path = require('path');23var fullWorkingDir = strykerParent.fullWorkingDir;24var pathToUse = path.join(fullWorkingDir, 'someDir');25console.log(pathToUse);26var strykerParent = require('stryker-parent');27var path = require('path');28var fullWorkingDir = strykerParent.fullWorkingDir;29var pathToUse = path.join(fullWorkingDir, '

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