How to use _atPath method in root

Best JavaScript code snippet using root

DetoxConfigErrorComposer.js

Source:DetoxConfigErrorComposer.js Github

copy

Full Screen

...16 .setDetoxConfigPath(this.filepath)17 .setDetoxConfig(this.contents)18 .setExtends(this._extends);19 }20 _atPath() {21 return this.filepath ? ` at path:\n${this.filepath}` : '.';22 }23 _inTheAppConfig() {24 const { type } = this._getSelectedConfiguration();25 if (type) {26 return `in configuration ${J(this.configurationName)}`;27 }28 return `in the app config`;29 }30 _getSelectedConfiguration() {31 return _.get(this.contents, ['configurations', this.configurationName]);32 }33 _focusOnConfiguration(postProcess = _.identity) {34 const configuration = _.get(this.contents, ['configurations', this.configurationName]);35 if (configuration === undefined) {36 return;37 }38 return {39 configurations: {40 [this.configurationName]: postProcess(configuration)41 },42 };43 }44 _getDeviceConfig(deviceAlias) {45 let config = undefined;46 this._focusOnDeviceConfig(deviceAlias, (value) => {47 config = value;48 return value;49 });50 return config;51 }52 _focusOnDeviceConfig(deviceAlias, postProcess = _.identity) {53 const { type, device } = this._getSelectedConfiguration();54 if (!deviceAlias) {55 if (type || !device) {56 return this._focusOnConfiguration(postProcess);57 } else {58 return this._focusOnConfiguration(c => {59 postProcess(c.device);60 return _.pick(c, 'device');61 });62 }63 }64 return {65 devices: {66 [device]: postProcess(this.contents.devices[device]),67 },68 };69 }70 _focusOnAppConfig(appPath, postProcess = _.identity) {71 const value = _.get(this.contents, appPath);72 return _.set({}, appPath, postProcess(value));73 }74 _resolveSelectedDeviceConfig(alias) {75 if (alias) {76 return this.contents.devices[alias];77 } else {78 const config = this._getSelectedConfiguration();79 return config.type ? config : config.device;80 }81 }82 _ensureProperty(...names) {83 return obj => {84 for (const name of names) {85 return _.set(obj, name, _.get(obj, name));86 }87 };88 }89 // region setters90 setConfigurationName(configurationName) {91 this.configurationName = configurationName || '';92 return this;93 }94 setDetoxConfigPath(filepath) {95 this.filepath = filepath || '';96 return this;97 }98 setDetoxConfig(contents) {99 this.contents = contents || null;100 return this;101 }102 setExtends(value) {103 this._extends = !!value;104 return this;105 }106 // endregion107 // region configuration/index108 noConfigurationSpecified() {109 return new DetoxConfigError({110 message: 'Cannot run Detox without a configuration file.',111 hint: _.endsWith(this.filepath, 'package.json')112 ? `Create an external .detoxrc.json configuration, or add "detox" configuration section to your package.json at:\n${this.filepath}`113 : 'Make sure to create external .detoxrc.json configuration in the working directory before you run Detox.'114 });115 }116 noConfigurationAtGivenPath(givenPath) {117 const message = this._extends118 ? `Failed to find the base Detox config specified in:\n{\n "extends": ${J(givenPath)}\n}`119 : `Failed to find Detox config at ${J(givenPath)}`;120 const hint = this._extends121 ? `Check your Detox config${this._atPath()}`122 : 'Make sure the specified path is correct.';123 return new DetoxConfigError({ message, hint });124 }125 failedToReadConfiguration(unknownError) {126 return new DetoxConfigError({127 message: 'An error occurred while trying to load Detox config from:\n' + this.filepath,128 debugInfo: unknownError,129 });130 }131 noConfigurationsInside() {132 return new DetoxConfigError({133 message: `There are no configurations in the given Detox config${this._atPath()}`,134 hint: `Examine the config:`,135 debugInfo: this.contents ? {136 configurations: undefined,137 ...this.contents,138 } : {},139 inspectOptions: { depth: 1 },140 });141 }142 cantChooseConfiguration() {143 const configurations = this.contents.configurations;144 return new DetoxConfigError({145 message: `Cannot determine which configuration to use from Detox config${this._atPath()}`,146 hint: 'Use --configuration to choose one of the following:\n' + hintList(configurations),147 });148 }149 noConfigurationWithGivenName() {150 const configurations = this.contents.configurations;151 return new DetoxConfigError({152 message: `Failed to find a configuration named ${J(this.configurationName)} in Detox config${this._atPath()}`,153 hint: 'Below are the configurations Detox was able to find:\n' + hintList(configurations),154 });155 }156 configurationShouldNotBeEmpty() {157 const name = this.configurationName;158 const configurations = this.contents.configurations;159 return new DetoxConfigError({160 message: `Cannot use an empty configuration ${J(name)}.`,161 hint: `A valid configuration should have "device" and "app" properties defined, e.g.:\n162{163 "apps": {164*-->"myApp.ios": {165| "type": "ios.app",166| "binaryPath": "path/to/app"167| },168| },169| "devices": {170|*->"simulator": {171|| "type": "ios.simulator",172|| "device": { type: "iPhone 12" }173|| },174||},175||"configurations": {176|| ${J(name)}: {177|*--- "device": "simulator",178*---- "app": "myApp.ios"179 }180 }181}182Examine your Detox config${this._atPath()}`,183 debugInfo: {184 configurations: {185 [name]: configurations[name],186 ...configurations,187 }188 },189 inspectOptions: { depth: 1 }190 });191 }192 // endregion193 // region composeDeviceConfig194 thereAreNoDeviceConfigs(deviceAlias) {195 return new DetoxConfigError({196 message: `Cannot use device alias ${J(deviceAlias)} since there is no "devices" config in Detox config${this._atPath()}`,197 hint: `\198You should create a dictionary of device configurations in Detox config, e.g.:199{200 "devices": {201*-> ${J(deviceAlias)}: {202| "type": "ios.simulator", // or "android.emulator", or etc...203| "device": { "type": "iPhone 12" }, // or e.g.: { "avdName": "Pixel_API_29" }204| }205| },206| "configurations": {207| ${J(this.configurationName)}: {208*---- "device": ${J(deviceAlias)},209 ...210 }211 }212}\n`,213 });214 }215 cantResolveDeviceAlias(alias) {216 return new DetoxConfigError({217 message: `Failed to find a device config ${J(alias)} in the "devices" dictionary of Detox config${this._atPath()}`,218 hint: 'Below are the device configurations Detox was able to find:\n'219 + hintList(this.contents.devices) + '\n\n'220 + `Check your configuration ${J(this.configurationName)}:`,221 debugInfo: this._getSelectedConfiguration(),222 inspectOptions: { depth: 0 },223 });224 }225 deviceConfigIsUndefined() {226 return new DetoxConfigError({227 message: `Missing "device" property in the selected configuration ${J(this.configurationName)}:`,228 hint: `It should be an alias to the device config, or the device config itself, e.g.:229{230 ...231 "devices": {232*-> "myDevice": {233| "type": "ios.simulator", // or "android.emulator", or etc...234| "device": { "type": "iPhone 12" }, // or e.g.: { "avdName": "Pixel_API_29" }235| }236| },237| "configurations": {238| ${J(this.configurationName)}: {239*---- "device": "myDevice", // or { type: 'ios.simulator', ... }240 ...241 },242 ...243 }244}245Examine your Detox config${this._atPath()}`,246 });247 }248 missingDeviceType(deviceAlias) {249 return new DetoxConfigError({250 message: `Missing "type" inside the device configuration.`,251 hint: `Usually, "type" property should hold the device type to test on (e.g. "ios.simulator" or "android.emulator").\n` +252 `Check that in your Detox config${this._atPath()}`,253 debugInfo: this._focusOnDeviceConfig(deviceAlias, this._ensureProperty('type')),254 inspectOptions: { depth: 3 },255 });256 }257 invalidDeviceType(deviceAlias, deviceConfig, innerError) {258 return new DetoxConfigError({259 message: `Invalid device type ${J(deviceConfig.type)} inside your configuration.`,260 hint: `Did you mean to use one of these?261${hintList(deviceAppTypes)}262P.S. If you intended to use a third-party driver, please resolve this error:263${innerError.message}264Please check your Detox config${this._atPath()}`,265 debugInfo: this._focusOnDeviceConfig(deviceAlias, this._ensureProperty('type')),266 inspectOptions: { depth: 3 },267 });268 }269 _invalidPropertyType(propertyName, expectedType, deviceAlias) {270 return new DetoxConfigError({271 message: `Invalid type of ${J(propertyName)} inside the device configuration.\n`272 + `Expected ${expectedType}.`,273 hint: `Check that in your Detox config${this._atPath()}`,274 debugInfo: this._focusOnDeviceConfig(deviceAlias),275 inspectOptions: { depth: 3 },276 });277 }278 _unsupportedPropertyByDeviceType(propertyName, supportedDeviceTypes, deviceAlias) {279 const { type } = this._getDeviceConfig(deviceAlias);280 return new DetoxConfigError({281 message: `The current device type ${J(type)} does not support ${J(propertyName)} property.`,282 hint: `You can use this property only with the following device types:\n` +283 hintList(supportedDeviceTypes) + '\n\n' +284 `Please fix your Detox config${this._atPath()}`,285 debugInfo: this._focusOnDeviceConfig(deviceAlias),286 inspectOptions: { depth: 4 },287 });288 }289 malformedDeviceProperty(deviceAlias, propertyName) {290 switch (propertyName) {291 case 'bootArgs':292 return this._invalidPropertyType('bootArgs', 'a string', deviceAlias);293 case 'utilBinaryPaths':294 return this._invalidPropertyType('utilBinaryPaths', 'an array of strings', deviceAlias);295 case 'forceAdbInstall':296 return this._invalidPropertyType('forceAdbInstall', 'a boolean value', deviceAlias);297 case 'gpuMode':298 return this._invalidPropertyType('gpuMode', "'auto' | 'host' | 'swiftshader_indirect' | 'angle_indirect' | 'guest'", deviceAlias);299 case 'headless':300 return this._invalidPropertyType('headless', 'a boolean value', deviceAlias);301 case 'readonly':302 return this._invalidPropertyType('readonly', 'a boolean value', deviceAlias);303 default:304 throw new DetoxInternalError(`Composing .malformedDeviceProperty(${propertyName}) is not implemented`);305 }306 }307 unsupportedDeviceProperty(deviceAlias, propertyName) {308 switch (propertyName) {309 case 'bootArgs':310 return this._unsupportedPropertyByDeviceType('bootArgs', ['ios.simulator', 'android.emulator'], deviceAlias);311 case 'forceAdbInstall':312 return this._unsupportedPropertyByDeviceType('forceAdbInstall', ['android.attached', 'android.emulator', 'android.genycloud'], deviceAlias);313 case 'gpuMode':314 return this._unsupportedPropertyByDeviceType('gpuMode', ['android.emulator'], deviceAlias);315 case 'headless':316 return this._unsupportedPropertyByDeviceType('headless', ['android.emulator'], deviceAlias);317 case 'readonly':318 return this._unsupportedPropertyByDeviceType('readonly', ['android.emulator'], deviceAlias);319 case 'utilBinaryPaths':320 return this._unsupportedPropertyByDeviceType('utilBinaryPaths', ['android.attached', 'android.emulator', 'android.genycloud'], deviceAlias);321 default:322 throw new DetoxInternalError(`Composing .unsupportedDeviceProperty(${propertyName}) is not implemented`);323 }324 }325 missingDeviceMatcherProperties(deviceAlias, expectedProperties) {326 const { type } = this._resolveSelectedDeviceConfig(deviceAlias);327 return new DetoxConfigError({328 message: `Invalid or empty "device" matcher inside the device config.`,329 hint: `It should have the device query to run on, e.g.:\n330{331 "type": ${J(type)},332 "device": ${expectedProperties.map(p => `{ ${J(p)}: ... }`).join('\n // or ')}333}334Check that in your Detox config${this._atPath()}`,335 debugInfo: this._focusOnDeviceConfig(deviceAlias),336 inspectOptions: { depth: 4 },337 });338 }339 // endregion340 // region composeAppsConfig341 thereAreNoAppConfigs(appAlias) {342 return new DetoxConfigError({343 message: `Cannot use app alias ${J(appAlias)} since there is no "apps" config in Detox config${this._atPath()}`,344 hint: `\345You should create a dictionary of app configurations in Detox config, e.g.:346{347 "apps": {348*-> ${J(appAlias)}: {349| "type": "ios.app", // or "android.apk", or etc...350| "binaryPath": "path/to/your/app", // ... and so on351| }352| },353| "configurations": {354| ${J(this.configurationName)}: {355*---- "app": ${J(appAlias)},356 ...357 }358 }359}\n`,360 });361 }362 cantResolveAppAlias(appAlias) {363 return new DetoxConfigError({364 message: `Failed to find an app config ${J(appAlias)} in the "apps" dictionary of Detox config${this._atPath()}`,365 hint: 'Below are the app configurations Detox was able to find:\n' + hintList(this.contents.apps) +366 `\n\nCheck your configuration ${J(this.configurationName)}:`,367 debugInfo: this._getSelectedConfiguration(),368 inspectOptions: { depth: 1 },369 });370 }371 appConfigIsUndefined(appPath) {372 const appProperty = appPath[2] === 'apps'373 ? `"apps": [..., "myApp", ...]`374 : `"app": "myApp"`;375 return new DetoxConfigError({376 message: `Undefined or empty app config in the selected ${J(this.configurationName)} configuration:`,377 hint: `\378It should be an alias to an existing app config in "apps" dictionary, or the config object itself, e.g.:379{380 "apps": {381*-> "myApp": {382| "type": "ios.app", // or "android.apk", or etc...383| "binaryPath": "path/to/your/app", // ... and so on384| }385| },386| "configurations": {387| ${J(this.configurationName)}: {388*---- ${appProperty}389 ...390 }391 }392Examine your Detox config${this._atPath()}`,393 debugInfo: this._focusOnConfiguration(),394 inspectOptions: { depth: 2 }395 });396 }397 malformedAppLaunchArgs(appPath) {398 return new DetoxConfigError({399 message: `Invalid type of "launchArgs" property ${this._inTheAppConfig()}.\nExpected an object:`,400 debugInfo: this._focusOnAppConfig(appPath),401 inspectOptions: { depth: 4 },402 });403 }404 missingAppBinaryPath(appPath) {405 return new DetoxConfigError({406 message: `Missing "binaryPath" property ${this._inTheAppConfig()}.\nExpected a string:`,407 debugInfo: this._focusOnAppConfig(appPath, this._ensureProperty('binaryPath')),408 inspectOptions: { depth: 4 },409 });410 }411 invalidAppType({ appPath, allowedAppTypes, deviceType }) {412 return new DetoxConfigError({413 message: `Invalid app "type" property in the app config.\nExpected ${allowedAppTypes.map(J).join(' or ')}.`,414 hint: `\415You have a few options:4161. Replace the value with the suggestion.4172. Use a correct device type with this app config. Currently you have ${J(deviceType)}.`,418 debugInfo: this._focusOnAppConfig(appPath),419 inspectOptions: { depth: 4 },420 });421 }422 duplicateAppConfig({ appName, appPath, preExistingAppPath }) {423 const config1 = { ..._.get(this.contents, preExistingAppPath) };424 config1.name = config1.name || '<GIVE IT A NAME>';425 const config2 = { ..._.get(this.contents, appPath) };426 config2.name = '<GIVE IT ANOTHER NAME>';427 const name = this.configurationName;428 const hintMessage = appName429 ? `Both apps use the same name ${J(appName)} — try giving each app a unique name.`430 : `The app configs are missing "name" property that serves to distinct them.`;431 return new DetoxConfigError({432 message: `App collision detected in the selected configuration ${J(name)}.`,433 hint: `\434${hintMessage}435detox → ${preExistingAppPath.join(' → ')}:436${DetoxConfigError.inspectObj(config1, { depth: 0 })}437detox → ${appPath.join(' → ')}:438${DetoxConfigError.inspectObj(config2, { depth: 0 })}439Examine your Detox config${this._atPath()}`,440 });441 }442 noAppIsDefined(deviceType) {443 const name = this.configurationName;444 const [appType] = deviceAppTypes[deviceType] || [''];445 const [appPlatform] = appType.split('.');446 const appAlias = appType ? `myApp.${appPlatform}` : 'myApp';447 return new DetoxConfigError({448 message: `The ${J(name)} configuration has no defined "app" config.`,449 hint: `There should be an inlined object or an alias to the app config, e.g.:\n450{451 "apps": {452*-->"${appAlias}": {453| "type": "${appType || 'someAppType'}",454| "binaryPath": "path/to/app"455| },456| },457| "configurations": {458| ${J(name)}: {459*---- "app": "${appAlias}"460 ...461 }462 }463}464Examine your Detox config${this._atPath()}`,465 debugInfo: this._focusOnConfiguration(),466 inspectOptions: { depth: 0 }467 });468 }469 oldSchemaHasAppAndApps() {470 return new DetoxConfigError({471 message: `Your configuration ${J(this.configurationName)} appears to be in a legacy format, which can’t contain "app" or "apps".`,472 hint: `Remove "type" property from configuration and use "device" property instead:\n` +473 `a) "device": { "type": ${J(this._getSelectedConfiguration().type)}, ... }\n` +474 `b) "device": "<alias-to-device>" // you should add that device configuration to "devices" with the same key` +475 `\n\nCheck your Detox config${this._atPath()}`,476 debugInfo: this._focusOnConfiguration(this._ensureProperty('type', 'device')),477 inspectOptions: { depth: 2 },478 });479 }480 ambiguousAppAndApps() {481 return new DetoxConfigError({482 message: `You can't have both "app" and "apps" defined in the ${J(this.configurationName)} configuration.`,483 hint: 'Use "app" if you have a single app to test.' +484 '\nUse "apps" if you have multiple apps to test.' +485 `\n\nCheck your Detox config${this._atPath()}`,486 debugInfo: this._focusOnConfiguration(this._ensureProperty('app', 'apps')),487 inspectOptions: { depth: 2 },488 });489 }490 multipleAppsConfigArrayTypo() {491 return new DetoxConfigError({492 message: `Invalid type of the "app" property in the selected configuration ${J(this.configurationName)}.`,493 hint: 'Rename "app" to "apps" if you plan to work with multiple apps.' +494 `\n\nCheck your Detox config${this._atPath()}`,495 debugInfo: this._focusOnConfiguration(this._ensureProperty('app')),496 inspectOptions: { depth: 2 },497 });498 }499 multipleAppsConfigShouldBeArray() {500 return new DetoxConfigError({501 message: `Expected an array in "apps" property in the selected configuration ${J(this.configurationName)}.`,502 hint: 'Rename "apps" to "app" if you plan to work with a single app.' +503 '\nOtherwise, make sure "apps" contains a valid array of app aliases or inlined app configs.' +504 `\n\nCheck your Detox config${this._atPath()}`,505 debugInfo: this._focusOnConfiguration(this._ensureProperty('apps')),506 inspectOptions: { depth: 3 },507 });508 }509 // endregion510 // region composeSessionConfig511 invalidServerProperty() {512 return new DetoxConfigError({513 message: `session.server property is not a valid WebSocket URL`,514 hint: `Expected something like "ws://localhost:8099".\nCheck that in your Detox config${this._atPath()}`,515 inspectOptions: { depth: 3 },516 debugInfo: _.omitBy({517 session: _.get(this.contents, ['session']),518 ...this._focusOnConfiguration(c => _.pick(c, ['session'])),519 }, _.isEmpty),520 });521 }522 invalidSessionIdProperty() {523 return new DetoxConfigError({524 message: `session.sessionId property should be a non-empty string`,525 hint: `Check that in your Detox config${this._atPath()}`,526 inspectOptions: { depth: 3 },527 debugInfo: _.omitBy({528 session: _.get(this.contents, ['session']),529 ...this._focusOnConfiguration(c => _.pick(c, ['session'])),530 }, _.isEmpty),531 });532 }533 invalidDebugSynchronizationProperty() {534 return new DetoxConfigError({535 message: `session.debugSynchronization should be a positive number`,536 hint: `Check that in your Detox config${this._atPath()}`,537 inspectOptions: { depth: 3 },538 debugInfo: _.omitBy({539 session: _.get(this.contents, ['session']),540 ...this._focusOnConfiguration(c => _.pick(c, ['session'])),541 }, _.isEmpty),542 });543 }544 cannotSkipAutostartWithMissingServer() {545 return new DetoxConfigError({546 message: `Cannot have both an undefined session.server URL and session.autoStart set to false`,547 hint: `Check that in your Detox config${this._atPath()}`,548 inspectOptions: { depth: 3 },549 debugInfo: _.omitBy({550 session: _.get(this.contents, ['session']),551 ...this._focusOnConfiguration(c => _.pick(c, ['session'])),552 }, _.isEmpty),553 });554 }555 // endregion556 missingBuildScript(appConfig) {557 return new DetoxConfigError({558 message: `\559Failed to build the app for the configuration ${J(this.configurationName)}, because \560there was no "build" script inside.561Check contents of your Detox config${this._atPath()}`,562 debugInfo: { build: undefined, ...appConfig },563 inspectOptions: { depth: 0 },564 });565 }566}567function hintList(items) {568 const values = Array.isArray(items) ? items : _.keys(items);569 return values.map(c => `* ${c}`).join('\n');570}...

Full Screen

Full Screen

DetoxConfigErrorBuilder.js

Source:DetoxConfigErrorBuilder.js Github

copy

Full Screen

...51 }52 cantChooseDeviceConfiguration() {53 const configurations = this.contents.configurations;54 return new DetoxConfigError({55 message: `Cannot determine which configuration to use from Detox config${_atPath(this.filepath)}`,56 hint: 'Use --configuration to choose one of the following:\n' + hintConfigurations(configurations),57 });58 }59 noDeviceConfigurationWithGivenName() {60 const configurations = this.contents.configurations;61 return new DetoxConfigError({62 message: `Failed to find a configuration named "${this.configurationName}" in Detox config${_atPath(this.filepath)}`,63 hint: 'Below are the configurations Detox was able to find:\n' + hintConfigurations(configurations),64 });65 }66 missingConfigurationType() {67 return new DetoxConfigError({68 message:69 `Missing "type" inside detox.configurations["${this.configurationName}"].\n` +70 `Usually, "type" property should hold the device type to test on (e.g. "ios.simulator" or "android.emulator").`,71 hint: `Check that in your Detox config${_atPath(this.filepath)}`,72 debugInfo: this._focusOnConfiguration(),73 inspectOptions: { depth: 2 },74 });75 }76 malformedAppLaunchArgs() {77 return new DetoxConfigError({78 message: `Invalid type of "launchArgs" property in detox.configurations["${this.configurationName}"]\nExpected an object.`,79 hint: `Check that in your Detox config${_atPath(this.filepath)}`,80 debugInfo: this._focusOnConfiguration(),81 inspectOptions: { depth: 2 },82 });83 }84 malformedAppLaunchArgsProperty(argKey) {85 return new DetoxConfigError({86 message: `Invalid property "${argKey}" inside detox.configurations["${this.configurationName}"].launchArgs\nExpected a string.`,87 hint: `Check that in your Detox config${_atPath(this.filepath)}`,88 debugInfo: this._focusOnConfiguration(c => _.pick(c, ['launchArgs'])),89 inspectOptions: { depth: 3 },90 });91 }92 malformedUtilBinaryPaths() {93 return new DetoxConfigError({94 message: `Invalid type of "utilBinaryPaths" property in detox.configurations["${this.configurationName}"]\nExpected an array of strings of paths.`,95 hint: `Check that in your Detox config${_atPath(this.filepath)}`,96 debugInfo: this._focusOnConfiguration(),97 inspectOptions: { depth: 2 },98 });99 }100 missingDeviceProperty() {101 return new DetoxConfigError({102 message: `Missing or empty "device" property inside detox.configurations["${this.configurationName}"].\n` +103 `It should hold the device query to run on (e.g. { "type": "iPhone 11 Pro" }, { "avdName": "Nexus_5X_API_29" }).`,104 hint: `Check that in your Detox config${_atPath(this.filepath)}`,105 debugInfo: this._focusOnConfiguration(),106 inspectOptions: { depth: 2 },107 });108 }109 invalidServerProperty() {110 return new DetoxConfigError({111 message: `session.server property is not a valid WebSocket URL`,112 hint: `Expected something like "ws://localhost:8099".\nCheck that in your Detox config${_atPath(this.filepath)}`,113 inspectOptions: { depth: 3 },114 debugInfo: _.omitBy({115 session: _.get(this.contents, ['session']),116 ...this._focusOnConfiguration(c => _.pick(c, ['session'])),117 }, _.isEmpty),118 });119 }120 invalidSessionIdProperty() {121 return new DetoxConfigError({122 message: `session.sessionId property should be a non-empty string`,123 hint: `Check that in your Detox config${_atPath(this.filepath)}`,124 inspectOptions: { depth: 3 },125 debugInfo: _.omitBy({126 session: _.get(this.contents, ['session']),127 ...this._focusOnConfiguration(c => _.pick(c, ['session'])),128 }, _.isEmpty),129 });130 }131 invalidDebugSynchronizationProperty() {132 return new DetoxConfigError({133 message: `session.debugSynchronization should be a positive number`,134 hint: `Check that in your Detox config${_atPath(this.filepath)}`,135 inspectOptions: { depth: 3 },136 debugInfo: _.omitBy({137 session: _.get(this.contents, ['session']),138 ...this._focusOnConfiguration(c => _.pick(c, ['session'])),139 }, _.isEmpty),140 });141 }142 missingBuildScript() {143 return new DetoxConfigError({144 message: `Could not find a build script inside "${this.configurationName}" configuration.`,145 hint: `Check contents of your Detox config${_atPath(this.filepath)}`,146 debugInfo: this._focusOnConfiguration(),147 inspectOptions: { depth: 2 },148 });149 }150 _focusOnConfiguration(postProcess = _.identity) {151 const configuration = _.get(this.contents, ['configurations', this.configurationName]);152 if (configuration === undefined) {153 return;154 }155 return {156 configurations: {157 [this.configurationName]: postProcess(configuration)158 },159 };160 }161}162function hintConfigurations(configurations) {163 return _.keys(configurations).map(c => `* ${c}`).join('\n')164}165function _atPath(configPath) {166 return configPath ? ` at path:\n${configPath}` : '.';167}...

Full Screen

Full Screen

class-connector.js

Source:class-connector.js Github

copy

Full Screen

1const childProcess = require('child_process');2class Connector {3 /**4 *5 * @param host6 * @param atPath7 */8 constructor(host, atPath = null) {9 this.defineTerminal();10 this._host = host;11 this._atPath = atPath;12 }13 get atPath() {14 return this._atPath;15 }16 set atPath(value) {17 this._atPath = value;18 }19 defineTerminal() {20 // for linux gnome21 this._terminal = 'gnome-terminal';22 }23 createCommand() {24 let command = `ssh -o 'StrictHostKeyChecking no' ${ this._host.sshUser }@${ this._host.sshHost}`;25 if (this._host.sshPort) {26 command += ` -p ${ this._host.sshPort}`;27 }28 if (this._host.sshKey) {29 // simple add key not works for me because I use usb device with ntfs system so I will use hack30 // command += ` -i '${ this._host.sshKey }'`;31 const cpFilePath = '~/.ssh/tmp_key_codnect2';32 command = `cp ${ this._host.sshKey} ${ cpFilePath}; chmod 400 ${ cpFilePath}; ssh-add ${ cpFilePath}; rm -f ${ cpFilePath}; ${ command}`;33 if(this._atPath !== null) {34 command = `cd ${ this._atPath}; ${ command}`;35 }36 } else if (this._host.sshPass) {37 command = `sshpass -p '${ this._host.sshPass.replace(/[$]/g, "\\$") }' ${ command}`;38 }39 if (this._host.sshDir) {40 command += ` -t 'cd ${ this._host.sshDir }; bash'`;41 }42 command = `(${ command }); bash;`;43 // command = '(cp /media/yaroslawww/YARO_PORT/portable/ssh/ws/path-app.pem ~/.ssh/ln_test; chmod 400 ~/.ssh/ln_test; ssh-add ~/.ssh/ln_test; rm -f ~/.ssh/ln_test; ssh -o \'StrictHostKeyChecking no\' ubuntu@pathmap.ca -p 22); bash;';44 return command;45 }46 createExecution(command = null) {47 if (command == null) {48 command = this.createCommand();49 }50 //console.log(command)51 switch (this._terminal) {52 case 'gnome-terminal':53 return `gnome-terminal --tab --active -- bash -c "${ command }"`;54 break;55 }56 }57 runSsh() {58 const command = this.createExecution();59 console.log(command);60 const openTerminalAtPath = childProcess.exec(command);61 openTerminalAtPath.on('error', (err) => {62 console.log(err);63 });64 }65 print() {66 console.log(`Connector host: ${ this._host.name}`);67 }68}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var _ = require('lodash');2var obj = {3 'a': [{ 'b': { 'c': 3 } }]4};5console.log(_.at(obj, ['a[0].b.c', 'a[0].b.c', 'a[0].b.c']));6console.log(_.at(['a', 'b', 'c'], [0, 2]));

Full Screen

Using AI Code Generation

copy

Full Screen

1const _ = require('lodash');2let root = {3 a: {4 b: {5 c: {6 d: {7 e: {8 f: {9 g: {10 h: {11 i: {12 j: {13 k: {14 l: {15 m: {16 n: {17 o: {18 p: {19 q: {20 r: {21 s: {22 t: {23 u: {24 v: {25 w: {26 x: {27 y: {28 z: {29 a: {30 b: {31 c: {32 d: {33 e: {34 f: {35 g: {36 h: {37 i: {38 j: {39 k: {40 l: {41 m: {42 n: {43 o: {44 p: {45 q: {46 r: {47 s: {48 t: {49 u: {50 v: {51 w: {52 x: {53 y: {54 z: {55 a: {56 b: {57 c: {58 d: {59 e: {60 f: {61 g: {62 h: {63 i: {64 j: {65 k: {66 l: {67 m: {68 n: {69 o: {70 p: {71 q: {72 r: {73 s: {74 t: {75 u: {76 v: {77 w: {78 x: {79 y: {80 z: {81 a: {82 b: {83 c: {84 d: {85 e: {86 f: {87 g: {88 h: {89 i: {90 j: {91 k: {92 l: {93 m: {94 n: {95 o: {

Full Screen

Using AI Code Generation

copy

Full Screen

1var obj = {2 b: {3 }4}5var result = root._atPath(obj, "b.c");6var obj = {7 b: {8 }9}10var result = root._atPath(obj, "b.d");11var obj = {12 b: {13 }14}15var result = root._atPath(obj, "b.d", 3);16var obj = {17 b: {18 }19}20var result = root._atPath(obj, "b.d", function() {21 return 3;22});23var obj = {24 b: {25 }26}27var result = root._atPath(obj, "b.d", function() {28 return 3;29});30var obj = {31 b: {32 }33}34var result = root._atPath(obj, "b.d", function() {35 return 3;36}, true);37var obj = {38 b: {39 }40}41var result = root._atPath(obj, "b.d", function() {42 return 3;43}, false);44console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('./root.js');2var path = require('path');3var pathToTest = path.resolve('./test.js');4var pathToRoot = path.resolve('./root.js');5var pathToRootFolder = path.resolve('./');6var pathToNonExistentFile = path.resolve('./nonExistent.js');7var pathToNonExistentFolder = path.resolve('./nonExistentFolder');8var pathToNonExistentFolderInRootFolder = path.resolve('./root/nonExistentFolder');9var pathToNonExistentFileInRootFolder = path.resolve('./root/nonExistent.js');10var pathToNonExistentFileInRootFolder2 = path.resolve('./root/nonExistentFolder/nonExistent.js');11var pathToRootFolderInRootFolder = path.resolve('./root/root');12var pathToRootFileInRootFolder = path.resolve('./root/root.js');13var pathToRootFileInRootFolder2 = path.resolve('./root/root/root.js');14var pathToRootFileInRootFolder3 = path.resolve('./root/root/root/root.js');15var pathToRootFileInRootFolder4 = path.resolve('./root/root/root/root/root.js');16var pathToRootFileInRootFolder5 = path.resolve('./root/root/root/root/root/root.js');17var pathToRootFileInRootFolder6 = path.resolve('./root/root/root/root/root/root/root.js');18var pathToRootFileInRootFolder7 = path.resolve('./root/root/root/root/root/root/root/root.js');19var pathToRootFileInRootFolder8 = path.resolve('./root/root/root/root/root/root/root/root/root.js');20var pathToRootFileInRootFolder9 = path.resolve('./root/root/root/root/root/root/root/root/root/root.js');21var pathToRootFileInRootFolder10 = path.resolve('./root/root/

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('root');2var rootObj = root.create();3var testObj = rootObj._atPath('test');4testObj.testMethod = function(){5 return 'testMethod';6}7testObj.testMethod();8### _atPath(path)9var root = require('root');10var rootObj = root.create();11var testObj = rootObj._atPath('test');12testObj.testMethod = function(){13 return 'testMethod';14}15testObj.testMethod();16### _atPath(path)17var root = require('root');18var rootObj = root.create();19var testObj = rootObj._atPath('test');20testObj.testMethod = function(){21 return 'testMethod';22}23testObj.testMethod();24### _atPath(path)25var root = require('root');26var rootObj = root.create();27var testObj = rootObj._atPath('test');28testObj.testMethod = function(){29 return 'testMethod';30}31testObj.testMethod();32### _atPath(path)33var root = require('root');

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('root');2var obj = root._atPath('test.json');3obj.test = 1;4var root = require('root');5var obj = root._atPath('test.json');6obj.test = 1;

Full Screen

Using AI Code Generation

copy

Full Screen

1var root = require('root');2var path = require('path');3var filePath = path.resolve('test.js');4var file = root.atPath(filePath);5var fileName = file.name;6var fileExtension = file.ext;7var fileContent = file.content;8var fileSize = file.size;9var fileLastModified = file.lastModified;10var fileAbsolutePath = file.absolutePath;11var fileRelativePath = file.relativePath;12var fileDir = file.dir;13var fileDirName = file.dirName;14var fileDirAbsolutePath = file.dirAbsolutePath;15var fileDirRelativePath = file.dirRelativePath;16var fileDirParent = file.dirParent;17var fileDirParentName = file.dirParentName;18var fileDirParentAbsolutePath = file.dirParentAbsolutePath;19var fileDirParentRelativePath = file.dirParentRelativePath;20var fileDirParentParent = file.dirParentParent;21var fileDirParentParentName = file.dirParentParentName;22var fileDirParentParentAbsolutePath = file.dirParentParentAbsolutePath;23var fileDirParentParentRelativePath = file.dirParentParentRelativePath;24var fileDirParentParentParent = file.dirParentParentParent;25var fileDirParentParentParentName = file.dirParentParentParentName;

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