From 43117710eb318eecfcc9a4055bfa043ffdd8f6e7 Mon Sep 17 00:00:00 2001 From: Justin Sabourin Date: Mon, 14 Jan 2019 14:44:06 -0500 Subject: [PATCH] fix: use JSON.stringify(..) for logging instead of String(..) --- client/src/client/workers/test-evaluator.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/client/src/client/workers/test-evaluator.js b/client/src/client/workers/test-evaluator.js index a74104cded..6e9090ac86 100644 --- a/client/src/client/workers/test-evaluator.js +++ b/client/src/client/workers/test-evaluator.js @@ -4,13 +4,18 @@ import __toString from 'lodash/toString'; const oldLog = self.console.log.bind(self.console); self.console.log = function proxyConsole(...args) { - self.postMessage({ type: 'LOG', data: String(args) }); + self.postMessage({ + type: 'LOG', + data: args.map(log => JSON.stringify(log)).join(' ') + }); return oldLog(...args); }; self.onmessage = async e => { /* eslint-disable no-unused-vars */ - const { code = '' } = e.data; + const { + code = '' + } = e.data; const assert = chai.assert; // Fake Deep Equal dependency const DeepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b); @@ -35,7 +40,9 @@ self.onmessage = async e => { if (typeof testResult === 'function') { await testResult(fileName => __toString(e.data.sources[fileName])); } - self.postMessage({ pass: true }); + self.postMessage({ + pass: true + }); } catch (err) { self.postMessage({ err: {