From c1db340e39d09a622c3fe1194d9d295b474d5c46 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sat, 21 Oct 2023 13:41:22 -0400 Subject: [PATCH] Fixing problem where Stimulus sometimes continued after the test Fixes: Error: Uncaught [ReferenceError: Node is not defined] --- src/LiveComponent/assets/test/tools.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/LiveComponent/assets/test/tools.ts b/src/LiveComponent/assets/test/tools.ts index 3a89e213a31..d50d1678a82 100644 --- a/src/LiveComponent/assets/test/tools.ts +++ b/src/LiveComponent/assets/test/tools.ts @@ -13,6 +13,10 @@ let activeTests: FunctionalTest[] = []; let application: Application; export function shutdownTests() { + if (application) { + application.stop(); + } + if (activeTests.length === 0) { // no test was run, apparently return; @@ -366,7 +370,9 @@ export function createTestForExistingComponent(component: Component): Functional export async function startStimulus(element: string|HTMLElement) { // start the Stimulus app just once per test suite - if (!application) { + if (application) { + await application.start(); + } else { application = Application.start(); application.register('live', LiveController); }