From e98ac4736e313a335474679cac46539f95415874 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Fri, 24 Nov 2023 13:15:43 +0100 Subject: [PATCH] DEV: Add "loop until failure" feature to QUnit (#24545) --- .../javascripts/discourse/tests/setup-tests.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/assets/javascripts/discourse/tests/setup-tests.js b/app/assets/javascripts/discourse/tests/setup-tests.js index 037d0e3f88b..745969cd5a7 100644 --- a/app/assets/javascripts/discourse/tests/setup-tests.js +++ b/app/assets/javascripts/discourse/tests/setup-tests.js @@ -139,6 +139,12 @@ function setupToolbar() { ?.content.querySelectorAll("script[data-discourse-plugin]") .forEach((script) => pluginNames.add(script.dataset.discoursePlugin)); + QUnit.config.urlConfig.push({ + id: "loop", + label: "Loop until failure", + value: "1", + }); + QUnit.config.urlConfig.push({ id: "target", label: "Target", @@ -356,6 +362,14 @@ export default function setupTests(config) { QUnit.config.autostart = false; } + if (getUrlParameter("loop")) { + QUnit.done(({ failed }) => { + if (failed === 0) { + window.location.reload(); + } + }); + } + handleLegacyParameters(); const target = getUrlParameter("target") || "core";