From d6307cc9077cd823af21179c7bc98a9f46e11fd0 Mon Sep 17 00:00:00 2001 From: Riken Shah Date: Fri, 12 Mar 2021 17:00:43 +0530 Subject: [PATCH] puppeteer_test: Add support to run tests with Firefox. This commit introduces the `--firefox` argument, which will allow us to run puppeteer tests with Firefox also. --- tools/lib/test_script.py | 4 +++- tools/test-js-with-puppeteer | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/lib/test_script.py b/tools/lib/test_script.py index d3d6fcdbf3..048f7b2958 100644 --- a/tools/lib/test_script.py +++ b/tools/lib/test_script.py @@ -121,8 +121,10 @@ def find_js_test_files(test_dir: str, files: Iterable[str]) -> List[str]: return test_files -def prepare_puppeteer_run() -> None: +def prepare_puppeteer_run(is_firefox: bool = False) -> None: os.chdir(ZULIP_PATH) + # This will determine if the browser will be firefox or chrome. + os.environ["PUPPETEER_PRODUCT"] = "firefox" if is_firefox else "chrome" subprocess.check_call(["node", "node_modules/puppeteer/install.js"]) os.makedirs("var/puppeteer", exist_ok=True) for f in glob.glob("var/puppeteer/puppeteer-failure*.png"): diff --git a/tools/test-js-with-puppeteer b/tools/test-js-with-puppeteer index 41e4ce7b8d..2692fcfdee 100755 --- a/tools/test-js-with-puppeteer +++ b/tools/test-js-with-puppeteer @@ -51,6 +51,7 @@ parser = argparse.ArgumentParser(usage) parser.add_argument("--interactive", action="store_true", help="Run tests interactively") add_provision_check_override_param(parser) +parser.add_argument("--firefox", action="store_true", help="Run tests with firefox.") parser.add_argument( "tests", nargs=argparse.REMAINDER, help="Specific tests to run; by default, runs all tests" ) @@ -127,7 +128,7 @@ or report and ask for help in chat.zulip.org""", external_host = "zulipdev.com:9981" assert_provisioning_status_ok(options.skip_provision_check) -prepare_puppeteer_run() +prepare_puppeteer_run(is_firefox=options.firefox) run_tests(options.tests, external_host) print(f"{OKGREEN}All tests passed!{ENDC}") sys.exit(0)