bazelbuild / rules_closure

Closure rules for Bazel
https://developers.google.com/closure
Apache License 2.0
152 stars 114 forks source link

Support testing with webdriver and rules_webtesting #567

Closed ptmphuong closed 1 year ago

ptmphuong commented 1 year ago

Added the option to test with Selenium webdriver + rules_webtesting in closure_js_test.

Usage:

Add setup_web_test_repositories() to WORKSPACE to load all repositories needed:

load("@io_bazel_rules_closure//closure:defs.bzl", "setup_web_test_repositories")
setup_web_test_repositories(
    chromium = True,
)

Example:

closure_js_test(
    name = "simple_test",
    timeout = "short",
    srcs = ["simple_test.js"],
    deps = [
        "@com_google_javascript_closure_library//closure/goog/testing:asserts",
        "@com_google_javascript_closure_library//closure/goog/testing:jsunit",
    ],
    browsers = ["@io_bazel_rules_webtesting//browsers:chromium-local"],
)
ptmphuong commented 1 year ago

Checking the CI's build issues. Any advise how to fix these?

1. Error loading chromedriver libraries (linux)

/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/ec321eb2cc2d0f8f91b676b6d4c66c29/execroot/io_bazel_rules_closure/bazel-out/k8-fastbuild/bin/closure/testing/test/dom_webtest_test_chromium-local.sh.runfiles/org_chromium_chromedriver_linux_x64/chromedriver_linux64/chromedriver: error while loading shared libraries: libxcb.so.1: cannot open shared object file: No such file or directory

Reason: some dependencies are missing, will need to download them manually, reported here.

My local machine works probably because I already have Chrome installed, and these packages are included there.

2. Spaces in runfile path (macOS)

link or target filename contains space on line 65: 'io_bazel_rules_closure/external/org_chromium_chromium_macos_x64/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Chromium Framework /private/var/tmp/_bazel_buildkite/0830ce27676c35f9ae4375d22ed52aef/external/org_chromium_chromium_macos_x64/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Chromium Framework'

This doesn't seem to be supported, reported here. They suggested adding the --nobuild_runfile_links or --experimental_inprocess_symlink_creation flag as a workaround.

The --experimental_inprocess_symlink_creation flag works for me.

gkdn commented 1 year ago

Looks like the tests are still failing.