Skip to content

Commit 341057f

Browse files
committed
build: switch to @aspect_rules_jasmine for jasmine_test
The previous `jasmine_test` rule from `@devinfra//bazel/jasmine:jasmine.bzl` was causing `ENOENT` errors locally when running tests. This was likely due to issues with path handling and the `chdir` behavior. This change replaces the usage of `@devinfra//bazel/jasmine:jasmine.bzl` with `@aspect_rules_jasmine//jasmine:defs.bzl`. The `jasmine_test` macro in `tools/defaults.bzl` is updated to work with the new rule, including adjustments to argument passing and path handling to ensure tests can locate necessary modules like `source-map-support`. This resolves the local `ENOENT` error and aligns with a more standard way of running jasmine tests with bazel.
1 parent ab3249e commit 341057f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tools/defaults.bzl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin")
2+
load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test")
23
load("@aspect_rules_js//js:defs.bzl", _js_binary = "js_binary")
3-
load("@devinfra//bazel/jasmine:jasmine.bzl", _jasmine_test = "jasmine_test")
44
load("@devinfra//bazel/ts_project:index.bzl", "strict_deps_test")
55
load("@rules_angular//src/ng_package:index.bzl", _ng_package = "ng_package")
66
load("@rules_angular//src/ts_project:index.bzl", _ts_project = "ts_project")
@@ -59,15 +59,21 @@ def ng_package(deps = [], extra_substitutions = {}, **kwargs):
5959
**kwargs
6060
)
6161

62-
def jasmine_test(args = [], tsconfig = "//:test-tsconfig", **kwargs):
62+
def jasmine_test(data = [], args = [], **kwargs):
63+
# Create relative path to root, from current package dir. Necessary as
64+
# we change the `chdir` below to the package directory.
65+
relative_to_root = "/".join([".."] * len(native.package_name().split("/")))
66+
6367
_jasmine_test(
6468
node_modules = "//:node_modules",
65-
tsconfig = tsconfig,
6669
chdir = native.package_name(),
6770
args = [
71+
"--require=%s/node_modules/source-map-support/register.js" % relative_to_root,
72+
# Escape so that the `js_binary` launcher triggers Bash expansion.
6873
"'**/*+(.|_)spec.js'",
6974
"'**/*+(.|_)spec.mjs'",
7075
"'**/*+(.|_)spec.cjs'",
7176
] + args,
77+
data = data + ["//:node_modules/source-map-support"],
7278
**kwargs
7379
)

0 commit comments

Comments
 (0)