How to use expectStrykerConfWritten method in stryker-parent

Best JavaScript code snippet using stryker-parent

stryker-initializer.spec.ts

Source:stryker-initializer.spec.ts Github

copy

Full Screen

...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;317 });318 });319 it('should log an error and quit when `stryker.conf.js` file already exists', async () => {320 fsExistsSync.resolves(true);321 expect(sut.initialize()).to.be.rejected;322 expect(testInjector.logger.error).calledWith(323 'Stryker config file "stryker.conf.js" already exists in the current directory. Please remove it and try again.'324 );325 });326 const stubTestRunners = (...testRunners: string[]) => {327 restClientSearch.get.withArgs('/v2/search?q=keywords:@stryker-mutator/test-runner-plugin').resolves({328 result: {329 results: testRunners.map((testRunner) => ({ package: { name: testRunner, version: '1.1.1' } })),330 },331 statusCode: 200,332 } as unknown as IRestResponse<PackageInfo[]>);333 };334 const stubMutators = (...mutators: string[]) => {335 restClientSearch.get.withArgs('/v2/search?q=keywords:@stryker-mutator/mutator-plugin').resolves({336 result: {337 results: mutators.map((mutator) => ({ package: { name: mutator, version: '1.1.1' } })),338 },339 statusCode: 200,340 } as unknown as IRestResponse<PackageInfo[]>);341 };342 const stubReporters = (...reporters: string[]) => {343 restClientSearch.get.withArgs('/v2/search?q=keywords:@stryker-mutator/reporter-plugin').resolves({344 result: {345 results: reporters.map((reporter) => ({ package: { name: reporter, version: '1.1.1' } })),346 },347 statusCode: 200,348 } as unknown as IRestResponse<PackageInfo[]>);349 };350 const stubPackageClient = (packageConfigPerPackage: Record<string, Record<string, unknown> | null>) => {351 Object.keys(packageConfigPerPackage).forEach((packageName) => {352 const pkgConfig: PackageInfo & { initStrykerConfig?: Record<string, unknown> } = {353 keywords: [],354 name: packageName,355 version: '1.1.1',356 };357 const cfg = packageConfigPerPackage[packageName];358 if (cfg) {359 pkgConfig.initStrykerConfig = cfg;360 }361 restClientPackage.get.withArgs(`/${packageName}@1.1.1/package.json`).resolves({362 result: pkgConfig,363 statusCode: 200,364 } as unknown as IRestResponse<PackageInfo[]>);365 });366 };367 interface StrykerInitAnswers {368 preset: string | null;369 testRunner: string;370 reporters: string[];371 packageManager: string;372 }373 function arrangeAnswers(answerOverrides?: Partial<StrykerInitAnswers>) {374 const answers: StrykerInitAnswers = Object.assign(375 {376 packageManager: 'yarn',377 preset: null,378 reporters: ['dimension', 'mars'],379 testRunner: 'awesome',380 },381 answerOverrides382 );383 inquirerPrompt.resolves(answers);384 }385 function resolvePresetConfig(presetConfigOverrides?: Partial<PresetConfiguration>) {386 const presetConfig: PresetConfiguration = {387 config: {},388 dependencies: [],389 guideUrl: '',390 };391 presetMock.createConfig.resolves(Object.assign({}, presetConfig, presetConfigOverrides));392 }393 function expectStrykerConfWritten(expectedRawConfig: string) {394 const [fileName, actualConfig] = fsWriteFile.getCall(0).args;395 expect(fileName).eq('stryker.conf.js');396 expect(normalizeWhitespaces(actualConfig as string)).deep.eq(normalizeWhitespaces(expectedRawConfig));397 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;2expectStrykerConfWritten();3var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;4expectStrykerConfWritten();5var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;6expectStrykerConfWritten();7var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;8expectStrykerConfWritten();9var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;10expectStrykerConfWritten();11var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;12expectStrykerConfWritten();13var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;14expectStrykerConfWritten();15var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;16expectStrykerConfWritten();17var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;18expectStrykerConfWritten();19var expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;20expectStrykerConfWritten();

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1const { expectStrykerConfWritten } = require('stryker-parent');2describe('test', () => {3 it('should write a stryker.conf.js file', () => {4 expectStrykerConfWritten();5 });6});

Full Screen

Using AI Code Generation

copy

Full Screen

1const expectStrykerConfWritten = require('stryker-parent').expectStrykerConfWritten;2describe('stryker.conf.js', () => {3 it('should be written', () => {4 expectStrykerConfWritten();5 });6});7module.exports = function(config) {8 config.set({9 });10};11{12 "scripts": {13 },14 "devDependencies": {15 }16}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { expectStrykerConfWritten } from 'stryker-parent';2describe('test', () => {3 it('should have written a stryker.conf.js file', () => {4 expectStrykerConfWritten();5 });6});

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1const { expectStrykerConfWritten } = require('stryker-parent');2describe('My first test', () => {3 it('should write a stryker.conf.js file', () => {4 expectStrykerConfWritten();5 });6});

Full Screen

Using AI Code Generation

copy

Full Screen

1const strykerParent = require('stryker-parent');2const strykerConfig = require('./stryker.conf.js');3const testFiles = ['test.js'];4describe('Stryker run', () => {5 it('should run stryker', () => {6 return strykerParent.expectStrykerConfWritten(strykerConfig, testFiles);7 });8});9const strykerParent = require('stryker-parent');10const strykerConfig = require('./stryker.conf.js');11const testFiles = ['test.js'];12describe('Stryker run', () => {13 it('should run stryker', () => {14 return strykerParent.expectStrykerConfWritten(strykerConfig, testFiles);15 });16});17 at Object.getAvailableMutators (C:\Users\user\AppData\Roaming\npm\node

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