fix: use JSON.stringify(..) for logging instead of String(..)

This commit is contained in:
Justin Sabourin
2019-01-14 14:44:06 -05:00
committed by Stuart Taylor
parent b494eebcc5
commit 43117710eb

View File

@ -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: {