Skip to content

Commit

Permalink
patch(vest): Wire async test up to isolate
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 11, 2023
1 parent 5f7c812 commit 16e97f0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/vest/src/core/test/testLevelFlowControl/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function runSyncTest(testObject: TIsolateTest): TestResult {
/**
* runs test, if async - adds to pending array
*/
function useRunTest(testObject: TIsolateTest): void {
function useRunTest(testObject: TIsolateTest): Promise<void> | undefined {
const VestBus = Bus.useBus();

// Run test callback.
Expand All @@ -74,10 +74,10 @@ function useRunTest(testObject: TIsolateTest): void {
// in case object is an enforce chain
if (isPromise(result)) {
VestTest.getData(testObject).asyncTest = result;
useRunAsyncTest(testObject);
} else {
onTestCompleted(VestBus, testObject);
return useRunAsyncTest(testObject);
}

onTestCompleted(VestBus, testObject);
} catch (e) {
// Probably unreachable. If we get here, it means that
// something was really wrong and should be reported.
Expand All @@ -94,7 +94,7 @@ function useRunTest(testObject: TIsolateTest): void {
/**
* Runs async test.
*/
function useRunAsyncTest(testObject: TIsolateTest): void {
function useRunAsyncTest(testObject: TIsolateTest): Promise<void> | undefined {
const { asyncTest, message } = VestTest.getData(testObject);

if (!isPromise(asyncTest)) return;
Expand All @@ -118,7 +118,7 @@ function useRunAsyncTest(testObject: TIsolateTest): void {
done();
});

asyncTest.then(done, fail);
return asyncTest.then(done, fail);
}

function onTestCompleted(VestBus: BusType, testObject: TIsolateTest) {
Expand Down

0 comments on commit 16e97f0

Please sign in to comment.