From dbccab5244830f2fe82b1a0c54bce6a683ec2c6e Mon Sep 17 00:00:00 2001
From: Nilay Majorwar <nilaymajorwar@gmail.com>
Date: Sat, 22 Jan 2022 18:49:34 +0530
Subject: [PATCH] Fix error handling in tests

---
 engines/test-utils.ts | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/engines/test-utils.ts b/engines/test-utils.ts
index 19b500b..0e0dd4e 100644
--- a/engines/test-utils.ts
+++ b/engines/test-utils.ts
@@ -29,10 +29,10 @@ export const executeProgram = async <T>(
 ): Promise<{ output: string; rendererState: T }> => {
   const controller = new ExecutionController(engine);
   controller.prepare(code, input);
-  return new Promise((resolve, reject) => {
+  return new Promise(async (resolve, reject) => {
     try {
       let output = "";
-      controller.executeAll({
+      const { error } = await controller.executeAll({
         interval: 0,
         onResult: (res) => {
           if (res.output) output += res.output;
@@ -41,6 +41,7 @@ export const executeProgram = async <T>(
           }
         },
       });
+      if (error) reject(error);
     } catch (error) {
       reject(error);
     }