diff --git a/remote/doc/Testing.md b/remote/doc/Testing.md index d0db9dc159b3..4bff77d3a781 100644 --- a/remote/doc/Testing.md +++ b/remote/doc/Testing.md @@ -149,6 +149,12 @@ test files have to be updated first. To select specific tests or test groups within a file define [exclusive tests] by adding the `.only` suffix like `it.only()` or `describe.only()`. +It is also possible, similar to how it works in CI, to run tests in chunks: + +```shell +% ./mach puppeteer-test --this-chunk=1 --total-chunks=2 +``` + More customizations for [Mocha] can be found in its own documentation. Test expectation metadata is collected in _remote/test/puppeteer-expected.json_ diff --git a/remote/mach_commands.py b/remote/mach_commands.py index bddfed8e0d8a..d6d14bfa27df 100644 --- a/remote/mach_commands.py +++ b/remote/mach_commands.py @@ -409,6 +409,8 @@ class PuppeteerRunner(MozbuildObject): binary = params.get("binary") headless = params.get("headless", False) product = params.get("product", "firefox") + this_chunk = params.get("this_chunk", "1") + total_chunks = params.get("total_chunks", "1") with_cdp = params.get("cdp", False) extra_options = {} @@ -458,26 +460,34 @@ class PuppeteerRunner(MozbuildObject): if product == "chrome": if with_cdp: if headless: - test_command = "test:chrome:headless" + test_command = "chrome-headless" else: - test_command = "test:chrome:headful" + test_command = "chrome-headful" elif headless: - test_command = "test:chrome:bidi" + test_command = "chrome-bidi" else: raise Exception( "Chrome doesn't support headful mode with the WebDriver BiDi protocol" ) elif product == "firefox": if with_cdp: - test_command = "test:firefox:cdp" + test_command = "firefox-cdp" elif headless: - test_command = "test:firefox:headless" + test_command = "firefox-headless" else: - test_command = "test:firefox:headful" + test_command = "firefox-headful" else: - test_command = "test:" + product + test_command = product - command = ["run", test_command, "--"] + mocha_options + command = [ + "run", + "test", + "--", + "--shard", + "'" + this_chunk + "-" + total_chunks + "'", + "--test-suite", + test_command, + ] + mocha_options prefs = {} for k, v in params.get("extra_prefs", {}).items(): @@ -586,6 +596,18 @@ def create_parser_puppeteer(): metavar="