log all requests with their response code

pull/21833/head
Bruno Windels 2018-07-27 18:58:37 +02:00
parent 29d688543d
commit 5129bb57b6
2 changed files with 5 additions and 6 deletions

View File

@ -54,14 +54,15 @@ function logConsole(page) {
function logXHRRequests(page) { function logXHRRequests(page) {
let buffer = ""; let buffer = "";
page.on('request', req => { page.on('requestfinished', async (req) => {
const type = req.resourceType(); const type = req.resourceType();
if (type === 'xhr' || type === 'fetch') { const response = await req.response();
buffer += `${req.method()} ${req.url()} \n`; //if (type === 'xhr' || type === 'fetch') {
buffer += `${type} ${response.status()} ${req.method()} ${req.url()} \n`;
// if (req.method() === "POST") { // if (req.method() === "POST") {
// buffer += " Post data: " + req.postData(); // buffer += " Post data: " + req.postData();
// } // }
} //}
}); });
return { return {
logs() { logs() {

View File

@ -54,8 +54,6 @@ async function runTests() {
await acceptServerNoticesInviteAndConsent(page, noticesName); await acceptServerNoticesInviteAndConsent(page, noticesName);
process.stdout.write('done\n'); process.stdout.write('done\n');
throw new Error('blubby');
const room = 'test'; const room = 'test';
process.stdout.write(`* creating room ${room} ... `); process.stdout.write(`* creating room ${room} ... `);
await createRoom(page, room); await createRoom(page, room);