1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

add argument for passing riot server, makes local testing easier

This commit is contained in:
Bruno Windels
2018-08-15 10:49:06 +02:00
parent 956688237a
commit 8507cf8258
2 changed files with 13 additions and 8 deletions

View File

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

View File

@ -18,18 +18,22 @@ const assert = require('assert');
const RiotSession = require('./src/session'); const RiotSession = require('./src/session');
const scenario = require('./src/scenario'); const scenario = require('./src/scenario');
const riotserver = 'http://localhost:5000'; const program = require('commander');
program
const noLogs = process.argv.indexOf("--no-logs") !== -1; .option('--no-logs', "don't output logs, document html on error", false)
const debug = process.argv.indexOf("--debug") !== -1; .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() { async function runTests() {
let sessions = []; let sessions = [];
console.log("program.riotUrl", program.riotUrl);
console.log("running tests ..."); console.log("running tests ...");
const options = {}; const options = {};
if (debug) { if (program.debug) {
options.slowMo = 20; options.slowMo = 20;
options.devtools = true;
options.headless = false; options.headless = false;
} }
if (process.env.CHROME_PATH) { if (process.env.CHROME_PATH) {
@ -39,7 +43,7 @@ async function runTests() {
} }
async function createSession(username) { async function createSession(username) {
const session = await RiotSession.create(username, options, riotserver); const session = await RiotSession.create(username, options, program.riotUrl);
sessions.push(session); sessions.push(session);
return session; return session;
} }
@ -50,7 +54,7 @@ async function runTests() {
} catch(err) { } catch(err) {
failure = true; failure = true;
console.log('failure: ', err); console.log('failure: ', err);
if (!noLogs) { if (!program.noLogs) {
for(let i = 0; i < sessions.length; ++i) { for(let i = 0; i < sessions.length; ++i) {
const session = sessions[i]; const session = sessions[i];
documentHtml = await session.page.content(); documentHtml = await session.page.content();
@ -84,4 +88,4 @@ async function runTests() {
runTests().catch(function(err) { runTests().catch(function(err) {
console.log(err); console.log(err);
process.exit(-1); process.exit(-1);
}); });