blob: 6a6039cadb30fb80964063cf82ad2db7e4013132 [file] [log] [blame] [edit]
load("@aspect_rules_js//js:defs.bzl", "js_run_binary")
load("//infra-sk:index.bzl", "nodejs_test", "ts_library")
nodejs_test(
name = "util_nodejs_test",
src = "util_nodejs_test.ts",
deps = [
":util_ts_lib",
"//:node_modules/@types/chai",
"//:node_modules/@types/express",
"//:node_modules/chai",
"//:node_modules/express",
"//:node_modules/puppeteer",
],
)
ts_library(
name = "util_ts_lib",
srcs = ["util.ts"],
data = select({
# Provides Google Chrome, libraries and fonts.
"@platforms//os:linux": [
":chrome",
"//:.puppeteerrc.js",
# TODO(lovisolo): Do we really need this? Can't we just use the :chrome target?
"@google_chrome//:all_files",
],
# We don't have hermetic support for Mac and Windows. Users are expected
# to have a working chrome installation already.
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
deps = [
"//:node_modules/puppeteer",
"//puppeteer-tests/chrome_downloader:chrome_executable_path_ts_lib",
],
)
# Hermetically downloads Chrome using Puppeteer's own code (@puppeteer/browsers NPM package). In
# conjunction with disabling Puppeteer's automatic downloading behavior in //.puppeteerrc.json,
# this guarantees that we get a Chrome version that is known to work well with Puppeteer, and that
# it is placed in a predictable location.
#
# This rule behaves like a fancy genrule, and can be depended upon by other targets as if it were a
# filegroup. See https://docs.aspect.build/rulesets/aspect_rules_js/docs/js_run_binary.
js_run_binary(
name = "chrome",
args = ["puppeteer-tests/chrome"],
mnemonic = "DownloadChrome",
out_dirs = ["chrome"],
stderr = "chrome.stderr",
stdout = "chrome.stdout",
tool = "//puppeteer-tests/chrome_downloader",
visibility = ["//visibility:public"],
)