How to use stubTestRunners method in stryker-parent

Best JavaScript code snippet using stryker-parent

stryker-initializer.spec.ts

Source:stryker-initializer.spec.ts Github

copy

Full Screen

...56 .injectClass(StrykerInitializer);57 });58 describe('initialize()', () => {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',309 configType: 'JSON',310 });311 restClientPackage.get.rejects();312 await sut.initialize();313 expect(testInjector.logger.warn).calledWith(314 'Could not fetch additional initialization config for dependency stryker-awesome-runner. You might need to configure it manually'315 );316 expect(fs.promises.writeFile).called;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var testRunner = require('stryker-mocha-runner');3var config = {4};5var options = {6};7var testRunner = stryker.testRunnerFactory().create('mocha', options);8testRunner.run({id: 1, name: 'test.js'}, ['test.js']).then(function (result) {9 console.log(result);10});11module.exports = function(config) {12 config.set({13 });14};15module.exports = function(config) {16 config.set({17 });18};19module.exports = function(config) {20 config.set({21 });22};23module.exports = function(config) {24 config.set({

Full Screen

Using AI Code Generation

copy

Full Screen

1const { stubTestRunners } = require('stryker-parent');2stubTestRunners({3});4module.exports = function(config) {5 config.set({6 preprocessors: {7 },8 babelPreprocessor: {9 options: {10 },11 filename: function(file) {12 return file.originalPath.replace(/\.js$/, '.es5.js');13 },14 sourceFileName: function(file) {15 return file.originalPath;16 }17 }18 });19};

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2stryker.stubTestRunners(['karma', 'mocha']);3stryker.stubTestRunners('karma,mocha');4var Stryker = require('stryker');5var stryker = new Stryker();6stryker.stubTestRunners(['karma', 'mocha']);7stryker.stubTestRunners('karma,mocha');8var Stryker = require('stryker');9var stryker = new Stryker();10stryker.stubTestRunners(['karma', 'mocha']);11stryker.stubTestRunners('karma,mocha');12var Stryker = require('stryker');13var stryker = new Stryker();14stryker.stubTestRunners(['karma', 'mocha']);15stryker.stubTestRunners('karma,mocha');16var Stryker = require('stryker');17var stryker = new Stryker();18stryker.stubTestRunners(['karma', 'mocha']);19stryker.stubTestRunners('karma,mocha');20var Stryker = require('stryker');21var stryker = new Stryker();22stryker.stubTestRunners(['karma', 'mocha']);23stryker.stubTestRunners('karma,mocha');24var Stryker = require('stryker');25var stryker = new Stryker();26stryker.stubTestRunners(['karma', 'mocha']);27stryker.stubTestRunners('karma,mocha');28var Stryker = require('stryker');29var stryker = new Stryker();30stryker.stubTestRunners(['karma', 'mocha']);

Full Screen

Using AI Code Generation

copy

Full Screen

1var stryker = require('stryker-parent');2var testRunner = require('./testRunner.js');3var options = {4};5stryker.stubTestRunners(options, testRunner, function (error, result) {6 if (error) {7 console.error(error);8 } else {9 console.log(result);10 }11});12var Q = require('q');13module.exports = function (config) {14 return {15 init: function () {16 return Q.resolve();17 },18 run: function (options) {19 return Q.resolve({20 tests: [{21 }]22 });23 }24 };25};

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