simplify use spa and android phones

This commit is contained in:
soulgalore 2019-01-01 22:28:58 +01:00
parent f476e5ae52
commit 6897dfce97
1 changed files with 31 additions and 1 deletions

View File

@ -1,6 +1,6 @@
'use strict';
let yargs = require('yargs'),
const yargs = require('yargs'),
path = require('path'),
packageInfo = require('../../package'),
merge = require('lodash.merge'),
@ -8,6 +8,7 @@ let yargs = require('yargs'),
cliUtil = require('./util'),
fs = require('fs'),
set = require('lodash.set'),
get = require('lodash.get'),
urlValidator = require('valid-url'),
toArray = require('../support/util').toArray,
grafanaConfig = require('../plugins/grafana/index').config,
@ -99,6 +100,14 @@ module.exports.parseCommandLine = function parseCommandLine() {
describe: 'How many times you want to test each page',
group: 'Browser'
})
.option('browsertime.spa', {
alias: 'spa',
describe:
'Convenient parameter to use if you test a SPA application: will automatically waity for X seconds after last network activity and use hash in file names.',
type: 'boolean',
default: false,
group: 'Browser'
})
.option('browsertime.connectivity.profile', {
alias: ['c', 'connectivity'],
default: browsertimeConfig.connectivity.profile,
@ -147,6 +156,13 @@ module.exports.parseCommandLine = function parseCommandLine() {
'Supply a Javascript that decides when the browser is finished loading the page and can start to collect metrics. The Javascript snippet is repeatedly queried to see if page has completed loading (indicated by the script returning true). Use it to fetch timings happening after the loadEventEnd.',
group: 'Browser'
})
.option('browsertime.pageCompleteWaitTime', {
alias: 'pageCompleteWaitTime',
describe:
'How long time you want to wait for your pageComplteteCheck to finish, after it is signaled to closed. Extra parameter passed on to your pageCompleteCheck.',
default: 5000,
group: 'Browser'
})
.option('browsertime.pageCompleteCheckInactivity', {
alias: 'pageCompleteCheckInactivity',
describe:
@ -996,6 +1012,20 @@ module.exports.parseCommandLine = function parseCommandLine() {
argv.browsertime.browser = 'firefox';
}
if (argv.android) {
set(
argv,
'browsertime.chrome.android.package',
get(argv, 'browsertime.chrome.android.package', 'com.android.chrome')
);
}
// Always use hash by default when you configure spa
if (argv.spa) {
set(argv, 'useHash', true);
set(argv, 'browsertime.useHash', true);
}
return {
urls: argv.multi ? argv._ : cliUtil.getURLs(argv._),
urlsMetaData: cliUtil.getAliases(argv._, argv.urlAlias),