How to use malformedDeviceProperty method in root

Best JavaScript code snippet using root

DetoxConfigErrorComposer.test.js

Source:DetoxConfigErrorComposer.test.js Github

copy

Full Screen

...177 : configurationType === 'inlined'178 ? config.configurations[configurationType].device179 : config.devices.aDevice;180 deviceConfig[propertyName] = invalidValue;181 expect(builder.malformedDeviceProperty(deviceAlias, propertyName)).toMatchSnapshot();182 });183 it('should throw on an unknown argument', () => {184 expect(() => builder.malformedDeviceProperty(undefined, 'unknown')).toThrowErrorMatchingSnapshot();185 });186 });187 describe('.unsupportedDeviceProperty', () => {188 test.each([189 ['bootArgs', 'inlined', '--no-window'],190 ['bootArgs', 'aliased', '--no-window'],191 ['forceAdbInstall', 'inlined', true],192 ['forceAdbInstall', 'aliased', false],193 ['gpuMode', 'inlined', 'auto'],194 ['gpuMode', 'aliased', 'auto'],195 ['headless', 'inlined', true],196 ['headless', 'aliased', true],197 ['readonly', 'inlined', false],198 ['readonly', 'aliased', false],...

Full Screen

Full Screen

composeDeviceConfig.test.js

Source:composeDeviceConfig.test.js Github

copy

Full Screen

...434 beforeEach(() => setConfig(deviceType, configType));435 it('should throw if .bootArgs are malformed (e.g., array)', () => {436 deviceConfig.bootArgs = ['--someArg'];437 expect(compose).toThrowError(438 errorComposer.malformedDeviceProperty(alias(), 'bootArgs')439 );440 });441 });442 test('should be disabled for custom devices', () => {443 setConfig('./customDriver', configType);444 deviceConfig.bootArgs = [0xAC, 0xDC];445 expect(compose).not.toThrowError();446 });447 });448 describe('.forceAdbInstall validation', () => {449 test.each([450 'ios.none',451 'ios.simulator',452 ])('cannot be used for iOS device (%j)', (deviceType) => {453 setConfig(deviceType, configType);454 deviceConfig.forceAdbInstall = false;455 expect(compose).toThrow(errorComposer.unsupportedDeviceProperty(alias(), 'forceAdbInstall'));456 });457 describe.each([458 'android.attached',459 'android.emulator',460 'android.genycloud',461 ])('for Android device (%j)', (deviceType) => {462 beforeEach(() => setConfig(deviceType, configType));463 it('should throw if .forceAdbInstall is malformed (e.g., string)', () => {464 deviceConfig.forceAdbInstall = 'yes';465 expect(compose).toThrowError(466 errorComposer.malformedDeviceProperty(alias(), 'forceAdbInstall')467 );468 });469 });470 test('should be disabled for custom devices', () => {471 setConfig('./customDriver', configType);472 deviceConfig.forceAdbInstall = /anything/;473 expect(compose).not.toThrowError();474 });475 });476 describe('.gpuMode validation', () => {477 test.each([478 'ios.none',479 'ios.simulator',480 'android.attached',481 'android.genycloud',482 ])('cannot be used for a non-emulator device (%j)', (deviceType) => {483 setConfig(deviceType, configType);484 deviceConfig.gpuMode = 'auto';485 expect(compose).toThrow(errorComposer.unsupportedDeviceProperty(alias(), 'gpuMode'));486 });487 describe('given android.emulator device', () => {488 beforeEach(() => setConfig('android.emulator', configType));489 test(`should throw if value is not a string`, () => {490 deviceConfig.gpuMode = ['auto'];491 expect(compose).toThrowError(errorComposer.malformedDeviceProperty(alias(), 'gpuMode'));492 });493 test(`should throw if value is not in (${KNOWN_GPU_MODES})`, () => {494 for (const gpuMode of KNOWN_GPU_MODES) {495 deviceConfig.gpuMode = gpuMode;496 expect(compose).not.toThrowError();497 deviceConfig.gpuMode = gpuMode.slice(1);498 expect(compose).toThrowError(errorComposer.malformedDeviceProperty(alias(), 'gpuMode'));499 }500 });501 });502 test('should be disabled for custom devices', () => {503 setConfig('./customDriver', configType);504 deviceConfig.gpuMode = class Whatever {};505 expect(compose).not.toThrowError();506 });507 });508 describe('.headless validation', () => {509 test.each([510 'ios.none',511 'ios.simulator',512 'android.attached',513 'android.genycloud',514 ])('cannot be used for a non-emulator device (%j)', (deviceType) => {515 setConfig(deviceType, configType);516 deviceConfig.headless = true;517 expect(compose).toThrow(errorComposer.unsupportedDeviceProperty(alias(), 'headless'));518 });519 describe('given android.emulator device', () => {520 beforeEach(() => setConfig('android.emulator', configType));521 test(`should throw if value is not a boolean (e.g., string)`, () => {522 deviceConfig.headless = `${Math.random() > 0.5}`; // string523 expect(compose).toThrowError(errorComposer.malformedDeviceProperty(alias(), 'headless'));524 });525 });526 test('should be disabled for custom devices', () => {527 setConfig('./customDriver', configType);528 deviceConfig.headless = NaN;529 expect(compose).not.toThrowError();530 });531 });532 describe('.readonly validation', () => {533 test.each([534 'ios.none',535 'ios.simulator',536 'android.attached',537 'android.genycloud',538 ])('cannot be used for a non-emulator device (%j)', (deviceType) => {539 setConfig(deviceType, configType);540 deviceConfig.readonly = true;541 expect(compose).toThrow(errorComposer.unsupportedDeviceProperty(alias(), 'readonly'));542 });543 describe('given android.emulator device', () => {544 beforeEach(() => setConfig('android.emulator', configType));545 test(`should throw if value is not a boolean (e.g., string)`, () => {546 deviceConfig.readonly = `${Math.random() > 0.5}`; // string547 expect(compose).toThrowError(errorComposer.malformedDeviceProperty(alias(), 'readonly'));548 });549 });550 test('should be disabled for custom devices', () => {551 setConfig('./customDriver', configType);552 deviceConfig.readonly = () => {};553 expect(compose).not.toThrowError();554 });555 });556 describe('.utilBinaryPaths validation', () => {557 test.each([558 'ios.none',559 'ios.simulator',560 ])('cannot be used for a non-Android device (%j)', (deviceType) => {561 setConfig(deviceType, configType);562 deviceConfig.utilBinaryPaths = [];563 expect(compose).toThrow(errorComposer.unsupportedDeviceProperty(alias(), 'utilBinaryPaths'));564 });565 describe.each([566 'android.attached',567 'android.emulator',568 'android.genycloud',569 ])('for Android device (%j)', (deviceType) => {570 beforeEach(() => setConfig(deviceType, configType));571 it('should throw if .utilBinaryPaths are malformed (array of non-strings)', () => {572 deviceConfig.utilBinaryPaths = [{ path: 'valid/path/not/in/array' }];573 expect(compose).toThrowError(574 errorComposer.malformedDeviceProperty(alias(), 'utilBinaryPaths')575 );576 });577 it('should throw if device.utilBinaryPaths are malformed (string)', () => {578 deviceConfig.utilBinaryPaths = 'valid/path/not/in/array';579 expect(compose).toThrowError(580 errorComposer.malformedDeviceProperty(alias(), 'utilBinaryPaths')581 );582 });583 });584 test('should be disabled for custom devices', () => {585 setConfig('./customDriver', configType);586 deviceConfig.utilBinaryPaths = 42;587 expect(compose).not.toThrowError();588 });589 });590 });591 });592 });...

Full Screen

Full Screen

composeDeviceConfig.js

Source:composeDeviceConfig.js Github

copy

Full Screen

...85 return;86 }87 if (deviceConfig.bootArgs != null) {88 if (!_.isString(deviceConfig.bootArgs)) {89 throw errorComposer.malformedDeviceProperty(deviceAlias, 'bootArgs');90 }91 if (deviceConfig.type !== 'ios.simulator' && deviceConfig.type !== 'android.emulator') {92 throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'bootArgs');93 }94 }95 if (deviceConfig.utilBinaryPaths != null) {96 if (!Array.isArray(deviceConfig.utilBinaryPaths)) {97 throw errorComposer.malformedDeviceProperty(deviceAlias, 'utilBinaryPaths');98 }99 if (deviceConfig.utilBinaryPaths.some(s => !_.isString(s))) {100 throw errorComposer.malformedDeviceProperty(deviceAlias, 'utilBinaryPaths');101 }102 if (!deviceConfig.type.match(/^android\.(attached|emulator|genycloud)$/)) {103 throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'utilBinaryPaths');104 }105 }106 if (deviceConfig.forceAdbInstall !== undefined) {107 if (!_.isBoolean(deviceConfig.forceAdbInstall)) {108 throw errorComposer.malformedDeviceProperty(deviceAlias, 'forceAdbInstall');109 }110 if (!deviceConfig.type.match(/^android\.(attached|emulator|genycloud)$/)) {111 throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'forceAdbInstall');112 }113 }114 if (deviceConfig.gpuMode !== undefined) {115 if (!_.isString(deviceConfig.gpuMode)) {116 throw errorComposer.malformedDeviceProperty(deviceAlias, 'gpuMode');117 }118 if (!deviceConfig.gpuMode.match(/^(auto|host|swiftshader_indirect|angle_indirect|guest)$/)) {119 throw errorComposer.malformedDeviceProperty(deviceAlias, 'gpuMode');120 }121 if (deviceConfig.type !== 'android.emulator') {122 throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'gpuMode');123 }124 }125 if (deviceConfig.headless !== undefined) {126 if (!_.isBoolean(deviceConfig.headless)) {127 throw errorComposer.malformedDeviceProperty(deviceAlias, 'headless');128 }129 if (deviceConfig.type !== 'android.emulator') {130 throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'headless');131 }132 }133 if (deviceConfig.readonly !== undefined) {134 if (!_.isBoolean(deviceConfig.readonly)) {135 throw errorComposer.malformedDeviceProperty(deviceAlias, 'readonly');136 }137 if (deviceConfig.type !== 'android.emulator') {138 throw errorComposer.unsupportedDeviceProperty(deviceAlias, 'readonly');139 }140 }141 if (_.isObject(deviceConfig.device)) {142 const expectedProperties = EXPECTED_DEVICE_MATCHER_PROPS[deviceConfig.type];143 if (!_.isEmpty(expectedProperties)) {144 const minimalShape = _.pick(deviceConfig.device, expectedProperties);145 if (_.isEmpty(minimalShape)) {146 throw errorComposer.missingDeviceMatcherProperties(deviceAlias, expectedProperties);147 }148 }149 }...

Full Screen

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 root 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