blob: 38e4808953620057a930d4f3886270f02b3cdc08 [file]
"Shows how you might create a macro for the autogeneratd Jest rule"
load("@npm//jest-cli:index.bzl", "jest", _jest_test = "jest_test")
def jest_test(name, srcs, deps, jest_config, **kwargs):
"A macro around the autogenerated jest_test rule"
templated_args = [
"--no-cache",
"--no-watchman",
"--ci",
"--colors",
]
templated_args.extend(["--config", "$(rootpath %s)" % jest_config])
for src in srcs:
templated_args.extend(["--runTestsByPath", "$(rootpath %s)" % src])
data = [jest_config] + srcs + deps + ["jest-reporter.js"]
_jest_test(
name = name,
data = data,
templated_args = templated_args,
**kwargs
)
# This rule is used specifically to update snapshots via `bazel run`
jest(
name = "%s.update" % name,
data = data,
templated_args = templated_args + ["-u"],
**kwargs
)