Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions JavaScript/1-stub/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@ const start = (tests) => {
}
const test = tests.shift();
console.log(`Started test: ${test.name}`);
try {
test((err) => {
if (err) {
failed++;
console.log(`Failed test: ${test.name}`);
console.log(err);
}
test((err) => {
if (err) {
failed++;
console.log(`Failed test: ${test.name}`);
console.log(err);
} else {
console.log(`Finished test: ${test.name}`);
setTimeout(runNext, 0);
});
} catch (err) {
failed++;
console.log(`Failed test: ${test.name}`);
console.log(err);
}
setTimeout(runNext, 0);
}
});
};
runNext();
};
Expand Down
10 changes: 4 additions & 6 deletions JavaScript/1-stub/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const runner = require('./runner.js');
const testCreateTask = (next) => {
const timer = setTimeout(() => {
const err = new Error('Can not create task');
assert.fail(err);
next(err);
}, 200);

Expand All @@ -33,7 +32,6 @@ const testCreateTask = (next) => {
const testExecuteTask = (next) => {
const timer = setTimeout(() => {
const err = new Error('Can not execute task');
assert.fail(err);
next(err);
}, 200);

Expand All @@ -57,7 +55,6 @@ const testExecuteTask = (next) => {
const testFailedTask = (next) => {
const timer = setTimeout(() => {
const err = new Error('Task expected to fail');
assert.fail(err);
next(err);
}, 200);

Expand All @@ -74,10 +71,11 @@ const testFailedTask = (next) => {
assert.strictEqual(err.message, 'Task failed');
} catch (err) {
error = err;
} finally {
clearTimeout(timer);
scheduler.stopAll();
next(error);
}
clearTimeout(timer);
scheduler.stopAll();
next(error);
});
};

Expand Down