From 982b79666721c07b8aa5af9eca3a6c72f5ffd92c Mon Sep 17 00:00:00 2001 From: Caleb Ukle Date: Mon, 22 May 2023 15:56:02 -0500 Subject: [PATCH] fix(testing): force dev server to exit when exiting. --- .../cypress/src/executors/cypress/cypress.impl.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/cypress/src/executors/cypress/cypress.impl.ts b/packages/cypress/src/executors/cypress/cypress.impl.ts index 81c68afd2ba6f4..b41b68e99fd7b8 100644 --- a/packages/cypress/src/executors/cypress/cypress.impl.ts +++ b/packages/cypress/src/executors/cypress/cypress.impl.ts @@ -67,19 +67,26 @@ export default async function cypressExecutor( options = normalizeOptions(options, context); // this is used by cypress component testing presets to build the executor contexts with the correct configuration options. process.env.NX_CYPRESS_TARGET_CONFIGURATION = context.configurationName; - let success; + let success: boolean; + const devServerIter = startDevServer(options, context); - for await (const devServerValues of startDevServer(options, context)) { + for await (const devServerValues of devServerIter) { try { success = await runCypress(devServerValues.baseUrl, { ...options, portLockFilePath: devServerValues.portLockFilePath, }); - if (!options.watch) break; + if (!options.watch) { + devServerIter.return(); + break; + } } catch (e) { logger.error(e.message); success = false; - if (!options.watch) break; + if (!options.watch) { + devServerIter.return(); + break; + } } }