Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
zjsunit: Support asynchronous tests.
Anders Kaseorga4a233b189c5
diff --git a/frontend_tests/zjsunit/index.js b/frontend_tests/zjsunit/index.jsindex def22d08b5f..2511e65d009 100644--- a/frontend_tests/zjsunit/index.js+++ b/frontend_tests/zjsunit/index.js@@ -89,7 +89,7 @@ function short_tb(tb) {require("../../static/js/templates"); // register Zulip extensions-function run_one_module(file) {+async function run_one_module(file) {zjquery.clear_initialize_function();zjquery.clear_all_elements();console.info("running test " + path.basename(file, ".js"));@@ -97,14 +97,14 @@ function run_one_module(file) {test.suite.length = 0;require(file);for (const f of test.suite) {- f();+ await f();}namespace.complain_about_unused_mocks();}test.set_verbose(files.length === 1);-try {+(async () => {for (const file of files) {namespace.start();namespace.set_global("window", window);@@ -129,7 +129,7 @@ try {namespace.mock_esm("../../static/js/realm_user_settings_defaults", zpage_params);require("../../static/js/realm_user_settings_defaults");- run_one_module(file);+ await run_one_module(file);if (blueslip.reset) {blueslip.reset();@@ -137,7 +137,7 @@ try {namespace.finish();}-} catch (error) /* istanbul ignore next */ {+})().catch((error) => /* istanbul ignore next */ {if (process.env.USING_INSTRUMENTED_CODE) {console.info(`TEST FAILED! Before using the --coverage option please make sure that your@@ -150,4 +150,4 @@ try {console.info(error);}process.exit(1);-}+});diff --git a/frontend_tests/zjsunit/test.js b/frontend_tests/zjsunit/test.jsindex 0b1532309f8..94917945e8c 100644--- a/frontend_tests/zjsunit/test.js+++ b/frontend_tests/zjsunit/test.js@@ -18,7 +18,7 @@ exports.set_verbose = (value) => {exports.suite = [];-function execute_test(label, f, opts) {+async function execute_test(label, f, opts) {const {sloppy_$} = opts || {};/* istanbul ignore if */@@ -33,8 +33,8 @@ function execute_test(label, f, opts) {try {namespace._start_template_mocking();- namespace.with_overrides((helpers) => {- f({+ await namespace.with_overrides(async (helpers) => {+ await f({...helpers,mock_template: namespace._mock_template,});