angular/aio/scripts/local_server_test.bzl
Joey Perrott ade024407d fix(docs-infra): remove part aio infra (#54929)
Remove parts of the aio infra

PR Close #54929
2024-04-02 18:38:04 +00:00

34 lines
1.2 KiB
Python

load("//tools:defaults.bzl", "nodejs_test")
def local_server_test(name, entry_point, serve_target, data = [], args = [], **kwargs):
"""Run a test script alongside a locally running http server.
Args:
name: Name of the test target
entry_point: The test script to run
serve_target: The contents to serve
data: Additional data required by the test script
args: Args to pass to the test script. Note: The special argument LOCALHOST_URL
will be substituted with the url pointing to the served contents.
**kwargs: remaining args to pass to test
"""
nodejs_test(
name = name,
testonly = True,
args = [
"$(rootpath @npm//light-server/bin:light-server)",
"$(rootpath %s)" % serve_target,
"$(rootpath %s)" % entry_point,
] + args,
data = [
"//aio/scripts:run-with-local-server.mjs",
"@npm//get-port",
"@npm//shelljs",
"@npm//tree-kill",
"@npm//light-server/bin:light-server",
serve_target,
entry_point,
] + data,
entry_point = "//aio/scripts:run-with-local-server.mjs",
**kwargs
)