From 8507cf82582f7810344a1b89594aa40ff2c3175e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 15 Aug 2018 10:49:06 +0200 Subject: [PATCH 1/2] add argument for passing riot server, makes local testing easier --- package.json | 1 + start.js | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index b5892a154a..8035fbb508 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "author": "", "license": "ISC", "dependencies": { + "commander": "^2.17.1", "puppeteer": "^1.6.0" } } diff --git a/start.js b/start.js index 229a9ab535..f1f7960555 100644 --- a/start.js +++ b/start.js @@ -18,18 +18,22 @@ const assert = require('assert'); const RiotSession = require('./src/session'); const scenario = require('./src/scenario'); -const riotserver = 'http://localhost:5000'; - -const noLogs = process.argv.indexOf("--no-logs") !== -1; -const debug = process.argv.indexOf("--debug") !== -1; +const program = require('commander'); +program + .option('--no-logs', "don't output logs, document html on error", false) + .option('--debug', "open browser window and slow down interactions", false) + .option('--riot-url [url]', "riot url to test", "http://localhost:5000") + .parse(process.argv); async function runTests() { let sessions = []; + console.log("program.riotUrl", program.riotUrl); console.log("running tests ..."); const options = {}; - if (debug) { + if (program.debug) { options.slowMo = 20; + options.devtools = true; options.headless = false; } if (process.env.CHROME_PATH) { @@ -39,7 +43,7 @@ async function runTests() { } async function createSession(username) { - const session = await RiotSession.create(username, options, riotserver); + const session = await RiotSession.create(username, options, program.riotUrl); sessions.push(session); return session; } @@ -50,7 +54,7 @@ async function runTests() { } catch(err) { failure = true; console.log('failure: ', err); - if (!noLogs) { + if (!program.noLogs) { for(let i = 0; i < sessions.length; ++i) { const session = sessions[i]; documentHtml = await session.page.content(); @@ -84,4 +88,4 @@ async function runTests() { runTests().catch(function(err) { console.log(err); process.exit(-1); -}); \ No newline at end of file +}); From 0e56250bc2cf2939d7e5ff8995888ecc559dfe79 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 15 Aug 2018 12:21:08 +0200 Subject: [PATCH 2/2] didnt mean to commit this --- start.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/start.js b/start.js index f1f7960555..ac9a2f8684 100644 --- a/start.js +++ b/start.js @@ -27,8 +27,6 @@ program async function runTests() { let sessions = []; - - console.log("program.riotUrl", program.riotUrl); console.log("running tests ..."); const options = {}; if (program.debug) {