mirror of https://github.com/vector-im/riot-web
write html, console and network logs to different files
parent
d978ce6b48
commit
6958fdb6e1
30
start.js
30
start.js
|
@ -28,7 +28,7 @@ program
|
||||||
.option('--slow-mo', "run tests slower to follow whats going on", false)
|
.option('--slow-mo', "run tests slower to follow whats going on", false)
|
||||||
.option('--dev-tools', "open chrome devtools in browser window", false)
|
.option('--dev-tools', "open chrome devtools in browser window", false)
|
||||||
.option('--no-sandbox', "same as puppeteer arg", false)
|
.option('--no-sandbox', "same as puppeteer arg", false)
|
||||||
.option('--error-log <n>', 'stdout, or a file to dump html and network logs in when the tests fail')
|
.option('--log-directory <dir>', 'a directory to dump html and network logs in when the tests fail')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
const hsUrl = 'http://localhost:5005';
|
const hsUrl = 'http://localhost:5005';
|
||||||
|
@ -68,14 +68,8 @@ async function runTests() {
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
failure = true;
|
failure = true;
|
||||||
console.log('failure: ', err);
|
console.log('failure: ', err);
|
||||||
if (program.errorLog) {
|
if (program.logDirectory) {
|
||||||
const logs = await createLogs(sessions);
|
await writeLogs(sessions, program.logDirectory);
|
||||||
if (program.errorLog === "stdout") {
|
|
||||||
process.stdout.write(logs);
|
|
||||||
} else {
|
|
||||||
console.log(`wrote logs to "${program.errorLog}"`);
|
|
||||||
fs.writeFileSync(program.errorLog, logs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,19 +88,19 @@ async function runTests() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createLogs(sessions) {
|
async function writeLogs(sessions, dir) {
|
||||||
let logs = "";
|
let logs = "";
|
||||||
for(let i = 0; i < sessions.length; ++i) {
|
for(let i = 0; i < sessions.length; ++i) {
|
||||||
const session = sessions[i];
|
const session = sessions[i];
|
||||||
|
const userLogDir = `${dir}/${session.username}`;
|
||||||
|
fs.mkdirSync(userLogDir);
|
||||||
|
const consoleLogName = `${userLogDir}/console.log`;
|
||||||
|
const networkLogName = `${userLogDir}/network.log`;
|
||||||
|
const appHtmlName = `${userLogDir}/app.html`;
|
||||||
documentHtml = await session.page.content();
|
documentHtml = await session.page.content();
|
||||||
logs = logs + `---------------- START OF ${session.username} LOGS ----------------\n`;
|
fs.writeFileSync(appHtmlName, documentHtml);
|
||||||
logs = logs + '\n---------------- console.log output:\n';
|
fs.writeFileSync(networkLogName, session.networkLogs());
|
||||||
logs = logs + session.consoleLogs();
|
fs.writeFileSync(consoleLogName, session.consoleLogs());
|
||||||
logs = logs + '\n---------------- network requests:\n';
|
|
||||||
logs = logs + session.networkLogs();
|
|
||||||
logs = logs + '\n---------------- document html:\n';
|
|
||||||
logs = logs + documentHtml;
|
|
||||||
logs = logs + `\n---------------- END OF ${session.username} LOGS ----------------\n`;
|
|
||||||
}
|
}
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue