fix: conditionally log non-assertion errors (JS)
console.logs and errors are only reported during the first evaluation of the user's code. This is because the code is evaluated for each test, but the logs will not change between the build phases of the tests. Errors thrown during testing (except failing assertions) are always reported. This is to inform the user that their code is faulty, rather than that it does not meet the challenge's requirements.
This commit is contained in:
committed by
mrugesh
parent
9a97d639f5
commit
04d2de96df
@@ -92,10 +92,18 @@ function* buildChallengeData(challengeData) {
|
||||
|
||||
function* executeTests(testRunner, tests, testTimeout = 5000) {
|
||||
const testResults = [];
|
||||
for (const { text, testString } of tests) {
|
||||
for (let i = 0; i < tests.length; i++) {
|
||||
const { text, testString } = tests[i];
|
||||
const newTest = { text, testString };
|
||||
// only the last test outputs console.logs to avoid log duplication.
|
||||
const firstTest = i === 1;
|
||||
try {
|
||||
const { pass, err } = yield call(testRunner, testString, testTimeout);
|
||||
const { pass, err } = yield call(
|
||||
testRunner,
|
||||
testString,
|
||||
testTimeout,
|
||||
firstTest
|
||||
);
|
||||
if (pass) {
|
||||
newTest.pass = true;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user