Skip to content

Commit

Permalink
added --standalone flag for android setup
Browse files Browse the repository at this point in the history
  • Loading branch information
itsspriyansh committed Mar 8, 2024
1 parent 9caa6b8 commit c0ee1a9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/commands/android/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const AVAILABLE_OPTIONS: AvailableOptions = {
appium: {
alias: [],
description: 'Make sure the final setup works with Appium out-of-the-box.'
},
standalone: {
alias: [],
description: 'Do standalone setup for Android Emulator (no Nightwatch-related requirements will be downloaded).'
}
};

Expand Down
18 changes: 12 additions & 6 deletions src/commands/android/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ export class AndroidSetup {
}
}

if (options.standalone && !options.browsers) {
configs.browsers = 'none';
}

return configs;
}

Expand Down Expand Up @@ -858,12 +862,14 @@ export class AndroidSetup {

// TODO: add major version of Chrome as suffix to chromedriver.
// Or, check the version of existing chromedriver using --version.
Logger.log('Checking if chromedriver is already downloaded...');
if (fs.existsSync(chromedriverDownloadPath)) {
Logger.log(` ${colors.green(symbols().ok)} chromedriver already present at '${chromedriverDownloadPath}'\n`);
} else {
Logger.log(` ${colors.red(symbols().fail)} chromedriver not found at '${chromedriverDownloadPath}'\n`);
downloadChromedriver = true;
if (!this.options.standalone) {
Logger.log('Checking if chromedriver is already downloaded...');
if (fs.existsSync(chromedriverDownloadPath)) {
Logger.log(` ${colors.green(symbols().ok)} chromedriver already present at '${chromedriverDownloadPath}'\n`);
} else {
Logger.log(` ${colors.red(symbols().fail)} chromedriver not found at '${chromedriverDownloadPath}'\n`);
downloadChromedriver = true;
}
}
} else if (stdout !== null) {
Logger.log(` ${colors.red(symbols().fail)} Chrome browser not found in the AVD.\n`);
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const run = () => {
try {
const argv = process.argv.slice(2);
const {_: args, ...options} = minimist(argv, {
boolean: ['install', 'setup', 'help', 'appium'],
boolean: ['install', 'setup', 'help', 'appium', 'standalone'],
alias: {
help: 'h',
mode: 'm',
Expand Down
15 changes: 15 additions & 0 deletions tests/unit_tests/commands/android/testIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,21 @@ describe('test getConfigFromOptions', function() {

configs = androidSetup.getConfigFromOptions({mode: true, browsers: []});
assert.deepStrictEqual(configs, {});

configs = androidSetup.getConfigFromOptions({standalone: true});
assert.deepStrictEqual(configs, {browsers: 'none'});

configs = androidSetup.getConfigFromOptions({standalone: true, browsers: false});
assert.deepStrictEqual(configs, {browsers: 'none'});

configs = androidSetup.getConfigFromOptions({standalone: true, browsers: 'chrome'});
assert.deepStrictEqual(configs, {browsers: 'chrome'});

configs = androidSetup.getConfigFromOptions({standalone: true, browsers: 'chrome,firefox'});
assert.deepStrictEqual(configs, {browsers: 'both'});

configs = androidSetup.getConfigFromOptions({standalone: true, browsers: 'brave'});
assert.deepStrictEqual(configs, {});
});
});

Expand Down

0 comments on commit c0ee1a9

Please sign in to comment.