Skip to content

Commit f6be548

Browse files
authored
Merge pull request #8 from oslabs-beta/katya/replacevm
Katya/replacevm
2 parents bade5f0 + 2b76893 commit f6be548

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

main_process/main_httpController.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ const httpController = {
229229
reqResObj.isHTTP2 = true;
230230
reqResObj.timeReceived = Date.now();
231231
response.headers = headers;
232+
response.status = headers[':status'];
232233

233234
// if cookie exists, parse the cookie(s)
234235
if (headers['set-cookie']) {
@@ -285,6 +286,16 @@ const httpController = {
285286

286287
reqResObj.response.events.push(dataEvent);
287288

289+
290+
console.log('this is reqresobj respons right beforetest', reqResObj.response);
291+
// check if there is a test script to run
292+
if (reqResObj.request.testContent) {
293+
reqResObj.response.testResult = testingController.runTest(
294+
reqResObj.request.testContent,
295+
reqResObj
296+
);
297+
}
298+
288299
event.sender.send('reqResUpdate', reqResObj);
289300
});
290301
},

main_process/main_testingController.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable no-useless-escape */
22
const { NodeVM } = require('vm2');
33
const chai = require('chai');
4+
const { status } = require('@grpc/grpc-js');
45

56
const testHttpController = {};
67

@@ -12,6 +13,13 @@ testHttpController.runTest = (
1213
) => {
1314
const { request } = reqResObj;
1415
let { response } = reqResObj;
16+
17+
console.log('this is response in backend', response);
18+
console.log('HSOULD BE HEADERS', response.headers);
19+
console.log('is status acessable', response.status);
20+
console.log('TRYING WITH BRackets', response.headers[':status']);
21+
// console.log('TRYING WITH just colon', response.headers:status);
22+
1523
// final test result objects will be stored in this array
1624
const testResults = [];
1725

@@ -70,9 +78,9 @@ testHttpController.runTest = (
7078
7179
addOneResult({
7280
message: errObj.message,
73-
status: 'FAIL',
81+
status: 'FAILhi',
7482
expected: errObj.expected,
75-
actual: errObj.actual,
83+
actual: err,
7684
});
7785
}
7886
`;
@@ -90,6 +98,7 @@ testHttpController.runTest = (
9098
vm.run(testScript, 'main.js');
9199
// deep clone the testResults array since sending functions, DOM elements, and non-cloneable
92100
// JS objects is not supported IPC channels past Electron 9
101+
// console.log('this is test results from back end', testResults);
93102
return JSON.parse(JSON.stringify(testResults));
94103
} catch (err) {
95104
console.log(

0 commit comments

Comments
 (0)