fix(client): reset test results before execution (#36029)
* fixed issue where tests should fail when code has error Signed-off-by: Stevo99 <Sfailla1983@gmail.com> * fix(client): Initialize tests as failing in case of build errors * fix: Reset tests to initial state when build fails * fix: simplify expression
This commit is contained in:
@ -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 };
|
||||
|
Reference in New Issue
Block a user