Best JavaScript code snippet using stryker-parent
options-validator.spec.ts
Source:options-validator.spec.ts
...108 describe('thresholds', () => {109 it('should be invalid with thresholds < 0 or > 100', () => {110 testInjector.options.thresholds.high = -1;111 testInjector.options.thresholds.low = 101;112 actValidationErrors('Config option "thresholds.high" must be >= 0, was -1.', 'Config option "thresholds.low" must be <= 100, was 101.');113 });114 it('should be invalid with thresholds.high null', () => {115 // @ts-expect-error invalid setting116 testInjector.options.thresholds.high = null;117 actValidationErrors('Config option "thresholds.high" has the wrong type. It should be a number, but was a null.');118 });119 it('should not allow high < low', () => {120 testInjector.options.thresholds.high = 20;121 testInjector.options.thresholds.low = 21;122 actValidationErrors('Config option "thresholds.high" should be higher than "thresholds.low".');123 });124 });125 it('should be invalid with invalid logLevel', () => {126 // @ts-expect-error invalid setting127 testInjector.options.logLevel = 'thisTestPasses';128 actValidationErrors(129 'Config option "logLevel" should be one of the allowed values ("off", "fatal", "error", "warn", "info", "debug", "trace"), but was "thisTestPasses".'130 );131 });132 it('should be invalid with non-numeric timeoutMS', () => {133 breakConfig('timeoutMS', 'break');134 actValidationErrors('Config option "timeoutMS" has the wrong type. It should be a number, but was a string.');135 });136 it('should be invalid with non-numeric timeoutFactor', () => {137 breakConfig('timeoutFactor', 'break');138 actValidationErrors('Config option "timeoutFactor" has the wrong type. It should be a number, but was a string.');139 });140 it('should be invalid with non-numeric dryRunTimeout', () => {141 breakConfig('dryRunTimeoutMinutes', 'break');142 actValidationErrors('Config option "dryRunTimeoutMinutes" has the wrong type. It should be a number, but was a string.');143 });144 it('should be invalid with negative numeric dryRunTimeout', () => {145 breakConfig('dryRunTimeoutMinutes', -1);146 actValidationErrors('Config option "dryRunTimeoutMinutes" must be >= 0, was -1.');147 });148 it('should report a deprecation warning and set disableBail for jest.enableBail', () => {149 testInjector.options.jest = { enableBail: false };150 sut.validate(testInjector.options);151 expect(testInjector.logger.warn).calledWith(152 'DEPRECATED. Use of "jest.enableBail" inside deprecated, please use "disableBail" instead. See https://stryker-mutator.io/docs/stryker-js/configuration#disablebail-boolean'153 );154 expect(testInjector.options.disableBail).true;155 });156 describe('plugins', () => {157 it('should be invalid with non-array plugins', () => {158 breakConfig('plugins', '@stryker-mutator/typescript');159 actValidationErrors('Config option "plugins" has the wrong type. It should be a array, but was a string.');160 });161 it('should be invalid with non-string array elements', () => {162 breakConfig('plugins', ['stryker-jest', 0]);163 actValidationErrors('Config option "plugins[1]" has the wrong type. It should be a string, but was a number.');164 });165 });166 describe('appendPlugins', () => {167 it('should be invalid with non-array plugins', () => {168 breakConfig('appendPlugins', '@stryker-mutator/typescript');169 actValidationErrors('Config option "appendPlugins" has the wrong type. It should be a array, but was a string.');170 });171 it('should be invalid with non-string array elements', () => {172 breakConfig('appendPlugins', ['stryker-jest', 0]);173 actValidationErrors('Config option "appendPlugins[1]" has the wrong type. It should be a string, but was a number.');174 });175 });176 describe('mutator', () => {177 it('should be invalid with non-string mutator', () => {178 // @ts-expect-error invalid setting179 testInjector.options.mutator = 1;180 actValidationErrors('Config option "mutator" has the wrong type. It should be a object, but was a number.');181 });182 it('should report a deprecation warning for "mutator.name"', () => {183 testInjector.options.mutator = {184 // @ts-expect-error invalid setting185 name: 'javascript',186 };187 sut.validate(testInjector.options);188 expect(testInjector.logger.warn).calledWith(189 'DEPRECATED. Use of "mutator.name" is no longer needed. You can remove "mutator.name" from your configuration. Stryker now supports mutating of JavaScript and friend files out of the box.'190 );191 });192 it('should report a deprecation warning for mutator as a string', () => {193 // @ts-expect-error invalid setting194 testInjector.options.mutator = 'javascript';195 sut.validate(testInjector.options);196 expect(testInjector.logger.warn).calledWith(197 'DEPRECATED. Use of "mutator" as string is no longer needed. You can remove it from your configuration. Stryker now supports mutating of JavaScript and friend files out of the box.'198 );199 });200 it('should accept mutationRange without a glob pattern', () => {201 testInjector.options.mutate = ['src/index.ts:1:0-2:0'];202 actAssertValid();203 });204 it('should not accept mutationRange for line < 1 (lines are 1 based)', () => {205 testInjector.options.mutate = ['src/app.ts:5:0-6:0', 'src/index.ts:0:0-2:0'];206 actValidationErrors('Config option "mutate[1]" is invalid. Mutation range "0:0-2:0" is invalid, line 0 does not exist (lines start at 1).');207 });208 it('should not accept mutationRange for start > end', () => {209 testInjector.options.mutate = ['src/index.ts:6-5'];210 actValidationErrors(211 'Config option "mutate[0]" is invalid. Mutation range "6-5" is invalid. The "from" line number (6) should be less then the "to" line number (5).'212 );213 });214 it('should not accept mutationRange with a glob pattern', () => {215 testInjector.options.mutate = ['src/index.*.ts:1:0-2:0'];216 actValidationErrors(217 'Config option "mutate[0]" is invalid. Cannot combine a glob expression with a mutation range in "src/index.*.ts:1:0-2:0".'218 );219 });220 it('should not accept mutationRange (with no column numbers) with a glob pattern', () => {221 testInjector.options.mutate = ['src/index.*.ts:1-2'];222 actValidationErrors('Config option "mutate[0]" is invalid. Cannot combine a glob expression with a mutation range in "src/index.*.ts:1-2".');223 });224 });225 describe('testFramework', () => {226 it('should report a deprecation warning', () => {227 testInjector.options.testFramework = '';228 sut.validate(testInjector.options);229 expect(testInjector.logger.warn).calledWith(230 'DEPRECATED. Use of "testFramework" is no longer needed. You can remove it from your configuration. Your test runner plugin now handles its own test framework integration.'231 );232 });233 });234 describe('reporters', () => {235 it('should be invalid with non-array reporters', () => {236 breakConfig('reporters', '@stryker-mutator/typescript');237 actValidationErrors('Config option "reporters" has the wrong type. It should be a array, but was a string.');238 });239 it('should be invalid with non-string array elements', () => {240 breakConfig('reporters', ['stryker-jest', 0]);241 actValidationErrors('Config option "reporters[1]" has the wrong type. It should be a string, but was a number.');242 });243 });244 describe('dashboard', () => {245 it('should be invalid for non-string project', () => {246 breakConfig('dashboard', { project: 23 });247 actValidationErrors('Config option "dashboard.project" has the wrong type. It should be a string, but was a number.');248 });249 it('should be invalid for non-string module', () => {250 breakConfig('dashboard', { module: 23 });251 actValidationErrors('Config option "dashboard.module" has the wrong type. It should be a string, but was a number.');252 });253 it('should be invalid for non-string version', () => {254 breakConfig('dashboard', { version: 23 });255 actValidationErrors('Config option "dashboard.version" has the wrong type. It should be a string, but was a number.');256 });257 it('should be invalid for non-string baseUrl', () => {258 breakConfig('dashboard', { baseUrl: 23 });259 actValidationErrors('Config option "dashboard.baseUrl" has the wrong type. It should be a string, but was a number.');260 });261 it('should be invalid for a wrong reportType', () => {262 breakConfig('dashboard', { reportType: 'empty' });263 actValidationErrors('Config option "dashboard.reportType" should be one of the allowed values ("full", "mutationScore"), but was "empty".');264 });265 });266 describe('maxConcurrentTestRunners', () => {267 it('should report a deprecation warning', () => {268 testInjector.options.maxConcurrentTestRunners = 8;269 sut.validate(testInjector.options);270 expect(testInjector.logger.warn).calledWith('DEPRECATED. Use of "maxConcurrentTestRunners" is deprecated. Please use "concurrency" instead.');271 });272 it('should not configure "concurrency" if "maxConcurrentTestRunners" is >= cpus-1', () => {273 testInjector.options.maxConcurrentTestRunners = 2;274 sinon.stub(os, 'cpus').returns([createCpuInfo(), createCpuInfo(), createCpuInfo()]);275 sut.validate(testInjector.options);276 expect(testInjector.options.concurrency).undefined;277 });278 it('should configure "concurrency" if "maxConcurrentTestRunners" is set with a lower value', () => {279 testInjector.options.maxConcurrentTestRunners = 1;280 sinon.stub(os, 'cpus').returns([createCpuInfo(), createCpuInfo(), createCpuInfo()]);281 sut.validate(testInjector.options);282 expect(testInjector.options.concurrency).eq(1);283 });284 });285 it('should be invalid with non-numeric maxTestRunnerReuse', () => {286 breakConfig('maxTestRunnerReuse', 'break');287 actValidationErrors('Config option "maxTestRunnerReuse" has the wrong type. It should be a number, but was a string.');288 });289 it('should warn when testRunnerNodeArgs are combined with the "command" test runner', () => {290 testInjector.options.testRunnerNodeArgs = ['--inspect-brk'];291 testInjector.options.testRunner = 'command';292 sut.validate(testInjector.options);293 expect(testInjector.logger.warn).calledWith(294 'Using "testRunnerNodeArgs" together with the "command" test runner is not supported, these arguments will be ignored. You can add your custom arguments by setting the "commandRunner.command" option.'295 );296 });297 describe('transpilers', () => {298 it('should report a deprecation warning', () => {299 testInjector.options.transpilers = ['stryker-jest'];300 sut.validate(testInjector.options);301 expect(testInjector.logger.warn).calledWith(302 'DEPRECATED. Support for "transpilers" is removed. You can now configure your own "buildCommand". For example, npm run build.'303 );304 });305 });306 it('should be invalid with invalid coverageAnalysis', () => {307 breakConfig('coverageAnalysis', 'invalid');308 actValidationErrors('Config option "coverageAnalysis" should be one of the allowed values ("off", "all", "perTest"), but was "invalid".');309 });310 function actValidationErrors(...expectedErrors: string[]) {311 expect(() => sut.validate(testInjector.options)).throws();312 for (const error of expectedErrors) {313 expect(testInjector.logger.error).calledWith(error);314 }315 expect(testInjector.logger.error).callCount(expectedErrors.length);316 }317 function actAssertValid() {318 sut.validate(testInjector.options);319 expect(testInjector.logger.fatal).not.called;320 expect(testInjector.logger.error).not.called;321 expect(testInjector.logger.warn).not.called;322 }323 function breakConfig(key: keyof StrykerOptions, value: any): void {324 const original = testInjector.options[key];...
Using AI Code Generation
1const { actValidationErrors } = require('stryker-parent');2const { actValidationErrors } = require('stryker-parent');3const { actValidationErrors } = require('stryker-parent');4const { actValidationErrors } = require('stryker-parent');5const { actValidationErrors } = require('stryker-parent');6const { actValidationErrors } = require('stryker-parent');7const { actValidationErrors } = require('stryker-parent');8const { actValidationErrors } = require('stryker-parent');9const { actValidationErrors } = require('stryker-parent');10const { actValidationErrors } = require('stryker-parent');11const { actValidationErrors } = require('stryker-parent');12const { actValidationErrors } = require('stryker-parent');13const { actValidationErrors } = require('stryker-parent');14const { actValidationErrors } = require('stryker-parent');15const { actValidationErrors } = require('stryker-parent');16const { actValidationErrors } = require('stryker-parent');17const { actValidationErrors } = require('stryker-parent');18const { actValidationErrors } = require('stryker-parent');19const { actValidationErrors } = require('stryker-parent');
Using AI Code Generation
1const { actValidationErrors } = require('@stryker-mutator/util');2const { actValidationErrors } = require('stryker-parent');3const { actValidationErrors } = require('@stryker-mutator/util');4const { actValidationErrors } = require('stryker-parent');5const { actValidationErrors } = require('@stryker-mutator/util');6const { actValidationErrors } = require('stryker-parent');7const { actValidationErrors } = require('@stryker-mutator/util');8const { actValidationErrors } = require('stryker-parent');9const { actValidationErrors } = require('@stryker-mutator/util');10const { actValidationErrors } = require('stryker-parent');11const { actValidationErrors } = require('@stryker-mutator/util');12const { actValidationErrors } = require('stryker-parent');13const { actValidationErrors } = require('@stryker-mutator/util');14const { actValidationErrors } = require('stryker-parent');15const { actValidationErrors } = require('@stryker-mutator/util');16const { actValidationErrors } = require('stryker-parent');
Using AI Code Generation
1const actValidationErrors = require('stryker-parent').actValidationErrors;2actValidationErrors('test');3const actValidationErrors = require('stryker-parent').actValidationErrors;4actValidationErrors('test');5const actValidationErrors = require('stryker-parent').actValidationErrors;6actValidationErrors('test');7const actValidationErrors = require('stryker-parent').actValidationErrors;8actValidationErrors('test');9const actValidationErrors = require('stryker-parent').actValidationErrors;10actValidationErrors('test');11const actValidationErrors = require('stryker-parent').actValidationErrors;12actValidationErrors('test');13const actValidationErrors = require('stryker-parent').actValidationErrors;14actValidationErrors('test');15const actValidationErrors = require('stryker-parent').actValidationErrors;16actValidationErrors('test');17const actValidationErrors = require('stryker-parent').actValidationErrors;18actValidationErrors('test');19const actValidationErrors = require('stryker-parent').actValidationErrors;20actValidationErrors('test');21const actValidationErrors = require('stryker-parent').actValidationErrors;22actValidationErrors('test');23const actValidationErrors = require('stryker-parent').actValidationErrors;24actValidationErrors('test');25const actValidationErrors = require('
Using AI Code Generation
1const strykerParent = require('stryker-parent');2const validationErrors = strykerParent.actValidationErrors;3const validationErrors = strykerParent.actValidationErrors;4const validationErrors = require('stryker-parent').actValidationErrors;5const validationErrors = require('stryker-parent').actValidationErrors;6const {actValidationErrors} = require('stryker-parent');7const {actValidationErrors} = require('stryker-parent');8const strykerParent = require('stryker-parent');9const {actValidationErrors} = strykerParent;10const {actValidationErrors} = strykerParent;11const {actValidationErrors} = require('stryker-parent');12const {actValidationErrors} = require('stryker-parent');13const strykerParent = require('stryker-parent');14const {actValidationErrors} = strykerParent;15const {actValidationErrors} = strykerParent;16const {actValidationErrors} = require('stryker-parent');17const {actValidationErrors} = require('stryker-parent');18const strykerParent = require('stryker-parent');19const {actValidationErrors} = strykerParent;20const {actValidationErrors} = strykerParent;21const {actValidationErrors} = require('stryker-parent');22const {actValidationErrors} = require('stryker-parent');23const strykerParent = require('stryker-parent');24const {actValidationErrors} = strykerParent;25const {actValidationErrors} = strykerParent;26const {actValidationErrors} = require('stryker-parent');27const {actValidationErrors} = require('stryker-parent');
Using AI Code Generation
1const strykerParent = require('stryker-parent');2const actValidationErrors = strykerParent.actValidationErrors;3const schema = strykerParent.schema;4const testConfig = {5};6actValidationErrors(testConfig, schema);7const strykerParent = require('stryker-parent');8const actValidationErrors = strykerParent.actValidationErrors;9const schema = strykerParent.schema;10const testConfig = {11};12actValidationErrors(testConfig, schema);13const strykerParent = require('stryker-parent');14const actValidationErrors = strykerParent.actValidationErrors;15const schema = strykerParent.schema;16const testConfig = {17};18actValidationErrors(testConfig, schema);19const strykerParent = require('stryker-parent');20const actValidationErrors = strykerParent.actValidationErrors;21const schema = strykerParent.schema;22const testConfig = {23};24actValidationErrors(testConfig, schema);25const strykerParent = require('stryker-parent');26const actValidationErrors = strykerParent.actValidationErrors;27const schema = strykerParent.schema;28const testConfig = {
Using AI Code Generation
1const { actValidationErrors } = require('stryker-parent');2actValidationErrors('error1', 'error2', 'error3', 'error4');3const { actValidationErrors } = require('stryker-parent');4actValidationErrors('error1', 'error2', 'error3', 'error4');5const { actValidationErrors } = require('stryker-parent');6actValidationErrors('error1', 'error2', 'error3', 'error4');7const { actValidationErrors } = require('stryker-parent');8actValidationErrors('error1', 'error2', 'error3', 'error4');9const { actValidationErrors } = require('stry
Using AI Code Generation
1const actValidationErrors = require('stryker-parent').actValidationErrors;2const errors = actValidationErrors('abc');3console.log(errors);4const actValidationErrors = require('stryker-parent').actValidationErrors;5const errors = actValidationErrors({ name: 'abc' });6console.log(errors);
Using AI Code Generation
1const { actValidationErrors } = require( 'stryker-parent' );2const { logValidationErrors } = require( 'stryker' );3const validationErrors = actValidationErrors( );4logValidationErrors( validationErrors );5const { actValidationErrors } = require( 'stryker-parent' );6const { logValidationErrors } = require( 'stryker' );7const validationErrors = actValidationErrors( );8logValidationErrors( validationErrors );9const { actValidationErrors } = require( 'stryker-parent' );10const { logValidationErrors } = require( 'stryker' );11const validationErrors = actValidationErrors( );12logValidationErrors( validationErrors );13const { actValidationErrors } = require( 'stryker-parent' );14const { logValidationErrors } = require( 'stryker' );15const validationErrors = actValidationErrors( );16logValidationErrors( validationErrors );17const { actValidationErrors } = require( 'stryker-parent' );18const { logValidationErrors } = require( 'stryker' );19const validationErrors = actValidationErrors( );20logValidationErrors( validationErrors );21const { actValidationErrors } = require( 'stryker-parent' );22const { logValidationErrors } = require( 'stryker' );23const validationErrors = actValidationErrors( );24logValidationErrors( validationErrors );
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!!