fix: improve challenge logs (#39395)

This commit is contained in:
Oliver Eyton-Williams
2020-08-11 16:32:18 +02:00
committed by GitHub
parent e1df87678b
commit 688a3dcc7b

View File

@ -32,11 +32,11 @@ const __utils = (() => {
self.postMessage(data); self.postMessage(data);
} }
function log(msg) { function log(...msgs) {
if (!(msg instanceof chai.AssertionError)) { if (msgs && msgs[0] && !(msgs[0] instanceof chai.AssertionError)) {
// discards the stack trace via toString as it only useful to debug the // discards the stack trace via toString as it only useful to debug the
// site, not a specific challenge. // site, not a specific challenge.
console.log(msg.toString()); console.log(...msgs.map(msg => msg.toString()));
} }
} }
@ -80,8 +80,15 @@ ${e.data.testString}`);
// rethrow error, since test failed. // rethrow error, since test failed.
throw err; throw err;
} }
// log build errors // log build errors unless they're related to import/export/require (there
__utils.log(err); // are challenges that use them and they should not trigger warnings)
if (
err.name !== 'ReferenceError' ||
(err.message !== 'require is not defined' &&
err.message !== 'exports is not defined')
) {
__utils.log(err);
}
// the tests may not require working code, so they are evaluated even if // the tests may not require working code, so they are evaluated even if
// the user code does not get executed. // the user code does not get executed.
testResult = eval(e.data.testString); testResult = eval(e.data.testString);