fix: proxy console logs during test evaluation (#37809)
This commit is contained in:
committed by
mrugesh
parent
08bbd893d3
commit
cd5131b07c
@ -38,12 +38,11 @@ const __utils = (() => {
|
|||||||
self.postMessage(data);
|
self.postMessage(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function log(err) {
|
function log(msg) {
|
||||||
if (!(err instanceof chai.AssertionError)) {
|
if (!(msg instanceof chai.AssertionError)) {
|
||||||
// report to both the browser and the fcc consoles, discarding the
|
// discards the stack trace via toString as it only useful to debug the
|
||||||
// stack trace via toString as it only useful to debug the site, not a
|
// site, not a specific challenge.
|
||||||
// specific challenge.
|
console.log(msg.toString());
|
||||||
console.log(err.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +65,7 @@ self.onmessage = async e => {
|
|||||||
// Fake Deep Equal dependency
|
// Fake Deep Equal dependency
|
||||||
const DeepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
const DeepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
||||||
|
|
||||||
// User code errors should be reported, but only once:
|
// Build errors should be reported, but only once:
|
||||||
__utils.toggleProxyLogger(e.data.firstTest);
|
__utils.toggleProxyLogger(e.data.firstTest);
|
||||||
/* eslint-enable no-unused-vars */
|
/* eslint-enable no-unused-vars */
|
||||||
try {
|
try {
|
||||||
@ -74,9 +73,12 @@ self.onmessage = async e => {
|
|||||||
let __userCodeWasExecuted = false;
|
let __userCodeWasExecuted = false;
|
||||||
/* eslint-disable no-eval */
|
/* eslint-disable no-eval */
|
||||||
try {
|
try {
|
||||||
|
// Logging is proxyed after the build to catch console.log messages
|
||||||
|
// generated during testing.
|
||||||
testResult = eval(`
|
testResult = eval(`
|
||||||
${e.data.build}
|
${e.data.build}
|
||||||
__userCodeWasExecuted = true;
|
__userCodeWasExecuted = true;
|
||||||
|
__utils.toggleProxyLogger(true);
|
||||||
${e.data.testString}
|
${e.data.testString}
|
||||||
`);
|
`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Reference in New Issue
Block a user