blob: 557bad3d1ad20d7b1a6e1445ff52e29b23281ba6 [file]
"Example macro wrapping the mocha CLI"
load("@npm//macro:mocha/package_json.bzl", "bin")
def mocha_test(name, srcs, args = [], data = [], env = {}, **kwargs):
bin.mocha_test(
name = name,
args = [
"--reporter",
"mocha-multi-reporters",
"--reporter-options",
"configFile=$(rootpath //macro:mocha_reporters.json)",
native.package_name() + "/*test.*js",
] + args,
data = data + srcs + [
"//macro:mocha_reporters.json",
"//macro:node_modules/mocha-multi-reporters",
"//macro:node_modules/mocha-junit-reporter",
],
env = dict(env, **{
# Add environment variable so that mocha writes its test xml
# to the location Bazel expects.
"MOCHA_FILE": "$$XML_OUTPUT_FILE",
}),
preserve_symlinks_main = False,
copy_data_to_bin = False,
**kwargs
)