async function executeTestScript()

in src/extension/src/scripts/run-tests.ts [140:166]


async function executeTestScript(projectName: string, packageJson: any) {
  console.log(cyanColor, `Execute test script in ${projectName}`);
  let testProcess;
  try {
    if (packageJson.scripts.test) {
      const frontendPath = path.join(testFolder, projectName, projectName, "frontend");
      testProcess = executeProcess("yarn test", frontendPath, "Error from running yarn test");

      testProcess.stdout.on("data", (data: any) => {
        console.log(data);
        if (data.toString().indexOf("FAILED") > -1) {
          throw new Error("Error: Test failed");
        }
      });
    } else {
      console.warn(yellowColor, `The test script was not found in ${projectName}`);
    }
  } catch (err) {
    console.error(redColor, `Error from execute test script in ${projectName}: ${err}`);
    throw err;
  }

  if (testProcess) {
    await sleep(80000);
    kill(testProcess.pid);
  }
}