Skip to content

Commit

Permalink
support async test
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Feb 27, 2021
1 parent 7a0ed07 commit 6adca6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 2 additions & 5 deletions tests/events-once.js
Expand Up @@ -175,7 +175,7 @@ function onceWithEventTargetError() {
});
}

Promise.all([
module.exports = Promise.all([
onceAnEvent(),
onceAnEventWithTwoArgs(),
catchesErrors(),
Expand All @@ -184,7 +184,4 @@ Promise.all([
onceWithEventTarget(),
onceWithEventTargetTwoArgs(),
onceWithEventTargetError()
]).catch(function (err) {
console.error(err.stack)
process.exit(1)
});
]);
10 changes: 9 additions & 1 deletion tests/index.js
Expand Up @@ -14,7 +14,15 @@ var require = function(file) {
t.on('end', function () { delete common.test; });
common.test = t;

try { orig_require(file); } catch (err) { t.fail(err); }
try {
var exp = orig_require(file);
if (exp && exp.then) {
exp.then(function () { t.end(); }, t.fail);
return;
}
} catch (err) {
t.fail(err);
}
t.end();
});
};
Expand Down

0 comments on commit 6adca6c

Please sign in to comment.