fix: improve challenge logs (#39395)
This commit is contained in:
committed by
GitHub
parent
e1df87678b
commit
688a3dcc7b
@ -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);
|
||||||
|
Reference in New Issue
Block a user