Skip to content

Commit

Permalink
Fixing problem where Stimulus sometimes continued after the test
Browse files Browse the repository at this point in the history
Fixes: Error: Uncaught [ReferenceError: Node is not defined]
  • Loading branch information
weaverryan committed Oct 21, 2023
1 parent 10c5591 commit c1db340
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/LiveComponent/assets/test/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit c1db340

Please sign in to comment.