How to use stubPackageClient method in stryker-parent

Best JavaScript code snippet using stryker-parent

stryker-initializer.spec.ts

Source:stryker-initializer.spec.ts Github

copy

Full Screen

...59 beforeEach(() => {60 stubTestRunners('@stryker-mutator/awesome-runner', 'stryker-hyper-runner', 'stryker-ghost-runner');61 stubMutators('@stryker-mutator/typescript', '@stryker-mutator/javascript-mutator');62 stubReporters('stryker-dimension-reporter', '@stryker-mutator/mars-reporter');63 stubPackageClient({64 '@stryker-mutator/awesome-runner': null,65 '@stryker-mutator/javascript-mutator': null,66 '@stryker-mutator/mars-reporter': null,67 '@stryker-mutator/typescript': null,68 '@stryker-mutator/webpack': null,69 'stryker-dimension-reporter': null,70 'stryker-ghost-runner': null,71 'stryker-hyper-runner': {72 files: [],73 someOtherSetting: 'enabled',74 },75 });76 fsWriteFile.resolves();77 presets.push(presetMock);78 });79 it('should prompt for preset, test runner, reporters, package manager and config type', async () => {80 arrangeAnswers({81 packageManager: 'yarn',82 reporters: ['dimension', 'mars'],83 testRunner: 'awesome',84 });85 await sut.initialize();86 expect(inquirerPrompt).callCount(5);87 const [promptPreset, promptTestRunner, promptReporters, promptPackageManagers, promptConfigTypes]: inquirer.ListQuestion[] = [88 inquirerPrompt.getCall(0).args[0],89 inquirerPrompt.getCall(1).args[0],90 inquirerPrompt.getCall(2).args[0],91 inquirerPrompt.getCall(3).args[0],92 inquirerPrompt.getCall(4).args[0],93 ];94 expect(promptPreset.type).to.eq('list');95 expect(promptPreset.name).to.eq('preset');96 expect(promptPreset.choices).to.deep.eq(['awesome-preset', new inquirer.Separator(), 'None/other']);97 expect(promptTestRunner.type).to.eq('list');98 expect(promptTestRunner.name).to.eq('testRunner');99 expect(promptTestRunner.choices).to.deep.eq(['awesome', 'hyper', 'ghost', new inquirer.Separator(), 'command']);100 expect(promptReporters.type).to.eq('checkbox');101 expect(promptReporters.choices).to.deep.eq(['dimension', 'mars', 'html', 'clear-text', 'progress', 'dashboard']);102 expect(promptPackageManagers.type).to.eq('list');103 expect(promptPackageManagers.choices).to.deep.eq(['npm', 'yarn']);104 expect(promptConfigTypes.type).to.eq('list');105 expect(promptConfigTypes.choices).to.deep.eq(['JSON', 'JavaScript']);106 });107 it('should immediately complete when a preset and package manager is chosen', async () => {108 inquirerPrompt.resolves({109 packageManager: 'npm',110 preset: 'awesome-preset',111 configType: 'JSON',112 });113 resolvePresetConfig();114 await sut.initialize();115 expect(inquirerPrompt).callCount(3);116 expect(out).calledWith('Done configuring stryker. Please review "stryker.conf.json", you might need to configure your test runner correctly.');117 expect(out).calledWith("Let's kill some mutants with this command: `stryker run`");118 });119 it('should correctly write and format the stryker js configuration file', async () => {120 const guideUrl = 'https://awesome-preset.org';121 const config = { awesomeConf: 'awesome' };122 childExec.resolves();123 resolvePresetConfig({124 config,125 guideUrl,126 });127 const expectedOutput = `/**128 * @type {import('@stryker-mutator/api/core').StrykerOptions}129 */ 130 module.exports = {131 "_comment": "This config was generated using 'stryker init'. Please see the guide for more information: https://awesome-preset.org",132 "awesomeConf": "${config.awesomeConf}"133 };`;134 inquirerPrompt.resolves({135 packageManager: 'npm',136 preset: 'awesome-preset',137 configType: 'JavaScript',138 });139 await sut.initialize();140 expectStrykerConfWritten(expectedOutput);141 expect(childExec).calledWith('npx prettier --write stryker.conf.js');142 });143 it('should handle errors when formatting fails', async () => {144 // Arrange145 const expectedError = new Error('Formatting fails');146 childExec.rejects(expectedError);147 inquirerPrompt.resolves({148 packageManager: 'npm',149 preset: 'awesome-preset',150 configType: 'JavaScript',151 });152 resolvePresetConfig();153 // Act154 await sut.initialize();155 // Assert156 expect(out).calledWith('Unable to format stryker.conf.js file for you. This is not a big problem, but it might look a bit messy 🙈.');157 expect(testInjector.logger.debug).calledWith('Prettier exited with error', expectedError);158 });159 it('should correctly load dependencies from the preset', async () => {160 resolvePresetConfig({ dependencies: ['my-awesome-dependency', 'another-awesome-dependency'] });161 inquirerPrompt.resolves({162 packageManager: 'npm',163 preset: 'awesome-preset',164 configType: 'JSON',165 });166 await sut.initialize();167 expect(fsWriteFile).calledOnce;168 expect(childExecSync).calledWith('npm i --save-dev my-awesome-dependency another-awesome-dependency', { stdio: [0, 1, 2] });169 });170 it('should correctly load configuration from a preset', async () => {171 resolvePresetConfig();172 inquirerPrompt.resolves({173 packageManager: 'npm',174 preset: 'awesome-preset',175 configType: 'JSON',176 });177 await sut.initialize();178 expect(inquirerPrompt).callCount(3);179 const [promptPreset, promptConfigType, promptPackageManager]: inquirer.ListQuestion[] = [180 inquirerPrompt.getCall(0).args[0],181 inquirerPrompt.getCall(1).args[0],182 inquirerPrompt.getCall(2).args[0],183 ];184 expect(promptPreset.type).to.eq('list');185 expect(promptPreset.name).to.eq('preset');186 expect(promptPreset.choices).to.deep.eq(['awesome-preset', new inquirer.Separator(), 'None/other']);187 expect(promptConfigType.type).to.eq('list');188 expect(promptConfigType.choices).to.deep.eq(['JSON', 'JavaScript']);189 expect(promptPackageManager.type).to.eq('list');190 expect(promptPackageManager.choices).to.deep.eq(['npm', 'yarn']);191 });192 it('should install any additional dependencies', async () => {193 inquirerPrompt.resolves({194 packageManager: 'npm',195 reporters: ['dimension', 'mars'],196 testRunner: 'awesome',197 configType: 'JSON',198 });199 await sut.initialize();200 expect(out).calledWith('Installing NPM dependencies...');201 expect(childExecSync).calledWith('npm i --save-dev @stryker-mutator/awesome-runner stryker-dimension-reporter @stryker-mutator/mars-reporter', {202 stdio: [0, 1, 2],203 });204 });205 it('should configure testRunner, reporters, and packageManager', async () => {206 inquirerPrompt.resolves({207 packageManager: 'npm',208 reporters: ['dimension', 'mars', 'progress'],209 testRunner: 'awesome',210 configType: 'JSON',211 });212 await sut.initialize();213 expect(fsWriteFile).calledOnce;214 const [fileName, content] = fsWriteFile.getCall(0).args;215 expect(fileName).eq('stryker.conf.json');216 const normalizedContent = normalizeWhitespaces(content as string);217 expect(normalizedContent).contains('"testRunner": "awesome"');218 expect(normalizedContent).contains('"packageManager": "npm"');219 expect(normalizedContent).contains('"coverageAnalysis": "perTest"');220 expect(normalizedContent).contains('"dimension", "mars", "progress"');221 });222 it('should configure the additional settings from the plugins', async () => {223 inquirerPrompt.resolves({224 packageManager: 'npm',225 reporters: [],226 testRunner: 'hyper',227 configType: 'JSON',228 });229 await sut.initialize();230 expect(fs.promises.writeFile).calledWith('stryker.conf.json', sinon.match('"someOtherSetting": "enabled"'));231 expect(fs.promises.writeFile).calledWith('stryker.conf.json', sinon.match('"files": []'));232 });233 it('should set "coverageAnalysis" to "off" when the command test runner is chosen', async () => {234 inquirerPrompt.resolves({235 packageManager: 'npm',236 reporters: [],237 testRunner: 'command',238 configType: 'JSON',239 });240 await sut.initialize();241 expect(fs.promises.writeFile).calledWith('stryker.conf.json', sinon.match('"coverageAnalysis": "off"'));242 });243 it('should reject with that error', () => {244 const expectedError = new Error('something');245 fsWriteFile.rejects(expectedError);246 inquirerPrompt.resolves({247 packageManager: 'npm',248 reporters: [],249 testRunner: 'ghost',250 configType: 'JSON',251 });252 return expect(sut.initialize()).to.eventually.be.rejectedWith(expectedError);253 });254 it('should recover when install fails', async () => {255 childExecSync.throws('error');256 inquirerPrompt.resolves({257 packageManager: 'npm',258 reporters: [],259 testRunner: 'ghost',260 configType: 'JSON',261 });262 await sut.initialize();263 expect(out).calledWith('An error occurred during installation, please try it yourself: "npm i --save-dev stryker-ghost-runner"');264 expect(fs.promises.writeFile).called;265 });266 });267 describe('initialize() when no internet', () => {268 it('should log error and continue when fetching test runners', async () => {269 restClientSearch.get.withArgs('/v2/search?q=keywords:@stryker-mutator/test-runner-plugin').rejects();270 stubMutators('stryker-javascript');271 stubReporters();272 stubPackageClient({ 'stryker-javascript': null, 'stryker-webpack': null });273 inquirerPrompt.resolves({274 packageManager: 'npm',275 reporters: ['clear-text'],276 configType: 'JSON',277 });278 await sut.initialize();279 expect(testInjector.logger.error).calledWith(280 'Unable to reach npms.io (for query /v2/search?q=keywords:@stryker-mutator/test-runner-plugin). Please check your internet connection.'281 );282 expect(fs.promises.writeFile).calledWith('stryker.conf.json', sinon.match('"testRunner": "command"'));283 });284 it('should log error and continue when fetching stryker reporters', async () => {285 stubTestRunners('stryker-awesome-runner');286 stubMutators('stryker-javascript');287 restClientSearch.get.withArgs('/v2/search?q=keywords:@stryker-mutator/reporter-plugin').rejects();288 inquirerPrompt.resolves({289 packageManager: 'npm',290 reporters: ['clear-text'],291 testRunner: 'awesome',292 configType: 'JSON',293 });294 stubPackageClient({ 'stryker-awesome-runner': null, 'stryker-javascript': null, 'stryker-webpack': null });295 await sut.initialize();296 expect(testInjector.logger.error).calledWith(297 'Unable to reach npms.io (for query /v2/search?q=keywords:@stryker-mutator/reporter-plugin). Please check your internet connection.'298 );299 expect(fs.promises.writeFile).called;300 });301 it('should log warning and continue when fetching custom config', async () => {302 stubTestRunners('stryker-awesome-runner');303 stubMutators();304 stubReporters();305 inquirerPrompt.resolves({306 packageManager: 'npm',307 reporters: ['clear-text'],308 testRunner: 'awesome',...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1const { stubPackageClient } = require('stryker-parent');2const { stubPackageClient } = require('stryker-parent');3const { stubPackageClient } = require('stryker-parent');4const { stubPackageClient } = require('stryker-parent');5const { stubPackageClient } = require('stryker-parent');6const { stubPackageClient } = require('stryker-parent');7const { stubPackageClient } = require('stryker-parent');8const { stubPackageClient } = require('stryker-parent');9const { stubPackageClient } = require('stryker-parent');10const { stubPackageClient } = require('stryker-parent');11const { stubPackageClient } = require('stryker-parent');12const { stubPackageClient } = require('stryker-parent');13const { stubPackageClient } = require('stryker-parent');14const { stubPackageClient } = require('stryker-parent');15const { stubPackageClient } = require('stryker-parent');16const { stubPackageClient } = require('stryker-parent');17const { stubPackageClient } = require('stryker-parent');18const { stubPackageClient } = require('stryker-parent');19const { stubPackageClient } = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { stubPackageClient } = require('stryker-parent');2const { stubPackageClient } = require('stryker-parent');3const { stubPackageClient } = require('stryker-parent');4const { stubPackageClient } = require('stryker-parent');5const { stubPackageClient } = require('stryker-parent');6const { stubPackageClient } = require('stryker-parent');7const { stubPackageClient } = require('stryker-parent');8const { stubPackageClient } = require('stryker-parent');9const { stubPackageClient } = require('stryker-parent');10const { stubPackageClient } = require('stryker-parent');11const { stubPackageClient } = require('stryker-parent');12const { stubPackageClient } = require('stryker-parent');13const { stubPackageClient } = require('stryker-parent');14const { stubPackageClient } = require('stryker-parent');15const { stubPackageClient } = require('stryker-parent');16const { stubPackageClient } = require('stryker-parent');17const { stubPackageClient } = require('stryker-parent');

Full Screen

Using AI Code Generation

copy

Full Screen

1var stubPackageClient = require('stryker-parent').stubPackageClient;2stubPackageClient('stryker-jasmine-runner');3var JasmineTestRunner = require('stryker-jasmine-runner').default;4var runner = new JasmineTestRunner({ jasmineConfigFile: 'jasmine.json' });5runner.run({ port: 9234, files: ['test.js'] }).then(function (result) {6 console.log(result);7});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { stubPackageClient } = require('stryker-parent');2const { expect } = require('chai');3describe('MyClass', function () {4 it('should use the stubbed package', function () {5 const myClass = new MyClass();6 expect(myClass.foo()).to.equal('bar');7 });8});9const package = require('package');10module.exports = class MyClass {11 foo() {12 return package.foo();13 }14};15module.exports = {16 foo() {17 return 'bar';18 }19};20{21}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { stubPackageClient } = require('stryker-parent');2stubPackageClient();3const { foo } = require('bar');4const { stubPackageClient } = require('stryker-parent');5stubPackageClient();6const { foo } = require('bar');7const { stubPackageClient } = require('stryker-parent');8stubPackageClient();9const { foo } = require('bar');10const { stubPackageClient } = require('stryker-parent');11stubPackageClient();12const { foo } = require('bar');13const { stubPackageClient } = require('stryker-parent');14stubPackageClient();15const { foo } = require('bar');16const { stubPackageClient } = require('stryker-parent');17stubPackageClient();18const { foo } = require('bar');19const { stubPackageClient } = require('stryker-parent');20stubPackageClient();21const { foo } = require('bar');22const { stubPackageClient } = require('stryker-parent');23stubPackageClient();24const { foo } = require('bar');25const { stubPackageClient } = require('stryker-parent');26stubPackageClient();27const { foo } = require('bar');28const { stubPackageClient } = require('stryker-parent');

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