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);
|
||||
}
|
||||
|
||||
function log(msg) {
|
||||
if (!(msg instanceof chai.AssertionError)) {
|
||||
function log(...msgs) {
|
||||
if (msgs && msgs[0] && !(msgs[0] instanceof chai.AssertionError)) {
|
||||
// discards the stack trace via toString as it only useful to debug the
|
||||
// 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.
|
||||
throw err;
|
||||
}
|
||||
// log build errors
|
||||
// log build errors unless they're related to import/export/require (there
|
||||
// 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 user code does not get executed.
|
||||
testResult = eval(e.data.testString);
|
||||
|
Reference in New Issue
Block a user