Merge pull request #9 from matrix-org/bwindels/commander

Add --riot-url option to run test against local dev server
This commit is contained in:
David Baker 2018-08-17 11:42:03 +01:00 committed by GitHub
commit 1e0baa823d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View file

@ -9,6 +9,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"commander": "^2.17.1",
"puppeteer": "^1.6.0"
}
}

View file

@ -18,18 +18,20 @@ 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("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 +41,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 +52,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();