diff --git a/client/src/templates/Challenges/redux/execute-challenge-saga.js b/client/src/templates/Challenges/redux/execute-challenge-saga.js index b6b7863b1f..246c256904 100644 --- a/client/src/templates/Challenges/redux/execute-challenge-saga.js +++ b/client/src/templates/Challenges/redux/execute-challenge-saga.js @@ -36,9 +36,16 @@ export function* executeChallengeSaga() { } const consoleProxy = yield channel(); + try { yield put(initLogs()); yield put(initConsole('// running tests')); + // reset tests to initial state + const tests = (yield select(challengeTestsSelector)).map( + ({ text, testString }) => ({ text, testString }) + ); + yield put(updateTests(tests)); + yield fork(logToConsole, consoleProxy); const proxyLogger = args => consoleProxy.put(args); @@ -51,7 +58,7 @@ export function* executeChallengeSaga() { proxyLogger, document ); - const testResults = yield executeTests(testRunner); + const testResults = yield executeTests(testRunner, tests); yield put(updateTests(testResults)); yield put(updateConsole('// tests completed')); @@ -79,9 +86,7 @@ function* buildChallengeData(challengeData) { } } -function* executeTests(testRunner) { - const tests = yield select(challengeTestsSelector); - const testTimeout = 5000; +function* executeTests(testRunner, tests, testTimeout = 5000) { const testResults = []; for (const { text, testString } of tests) { const newTest = { text, testString };