Documentation Index
Fetch the complete documentation index at: https://docs.aspect.build/llms.txt
Use this file to discover all available pages before exploring further.
Documentation for @aspect_rules_jasmine@v2.0.2 — View source
Rule: jasmine_test_rule
Runs tests in NodeJS using the Jasmine test runner.
Kind: Test rule
Attributes
A unique name for this target.
Working directory to run the binary or test in, relative to the workspace.By default,
js_binary runs in the root of the output tree.To run in the directory containing the js_binary usechdir = package_name()(or if you’re in a macro, use native.package_name())WARNING: this will affect other paths passed to the program, either as arguments or in configuration files,
which are workspace-relative.You may need ../../ segments to re-relativize such paths to the new working directory.
In a BUILD file you could do something like this to point to the output path:Runtime dependencies of the program.The transitive closure of the
data dependencies will be available in
the .runfiles folder for this binary/test.NB: data files are copied to the Bazel output tree before being passed
as inputs to runfiles. See copy_data_to_bin docstring for more info.The main script which is evaluated by node.js.This is the module referenced by the
require.main property in the runtime.This must be a target that provides a single file or a DirectoryPathInfo
from @aspect_bazel_lib//lib::directory_path.bzl.See https://github.com/aspect-build/bazel-lib/blob/main/docs/directory_path.md
for more info on creating a target that provides a DirectoryPathInfo.Whether runfiles are enabled in the current build configuration.Typical usage of this rule is via a macro which automatically sets this
attribute based on a
config_setting rule.Environment variables of the action.Subject to $(location)
and “Make variable” substitution if
expand_env is set to True.Enables $(location)
and “Make variable” substitution for
fixed_args.This comes at some analysis-time cost even for a set of args that does not have any expansions.Enables $(location)
and “Make variable” substitution for
env.This comes at some analysis-time cost even for a set of envs that does not have any expansions.Fixed command line arguments to pass to the Node.js when this
binary target is executed.Subject to $(location)
and “Make variable” substitution if
expand_args is set to True.Unlike the built-in args, which are only passed to the target when it is
executed either by the bazel run command or as a test, fixed_args are baked
into the generated launcher script so are always passed even when the binary
target is run outside of Bazel directly from the launcher script.fixed_args are passed before the ones specified in args and before ones
that are specified on the bazel run or bazel test command line.See https://bazel.build/reference/be/common-definitions#common-attributes-binaries
for more info on the built-in args attribute.Options to pass to the node invocation on the command line.https://nodejs.org/api/cli.htmlThese options are passed directly to the node invocation on the command line.
Options passed here will take precendence over options passed via
the NODE_OPTIONS environment variable. Options passed here are not added
to the NODE_OPTIONS environment variable so will not be automatically
picked up by child processes that inherit that enviroment variable.
The expected exit code.Can be used to write tests that are expected to fail.
Set the logging level.Log from are written to stderr. They will be supressed on success when running as the tool
of a js_run_binary when silent_on_success is True. In that case, they will be shown
only on a build failure along with the stdout & stderr of the node tool being run.Log levels: fatal, error, warn, info, debug
Patch the to Node.js
fs API (https://nodejs.org/api/fs.html) for this node program
to prevent the program from following symlinks out of the execroot, runfiles and the sandbox.When enabled, js_binary patches the Node.js sync and async fs API functions lstat,
readlink, realpath, readdir and opendir so that the node program being
run cannot resolve symlinks out of the execroot and the runfiles tree. When in the sandbox,
these patches prevent the program being run from resolving symlinks out of the sandbox.When disabled, node programs can leave the execroot, runfiles and sandbox by following symlinks
which can lead to non-hermetic behavior.When True,
sources from JsInfo providers in data targets are included in the runfiles of the target.When True,
transitive_sources from JsInfo providers in data targets are included in the runfiles of the target.When True,
types from JsInfo providers in data targets are included in the runfiles of the target.Defaults to False since types are generally not needed at runtime and introducing them could slow down developer round trip
time due to having to generate typings on source file changes.NB: These are types from direct data dependencies only. You may also need to set include_transitive_types to True.When True,
transitive_types from JsInfo providers in data targets are included in the runfiles of the target.Defaults to False since types are generally not needed at runtime and introducing them could slow down developer round trip
time due to having to generate typings on source file changes.When True, files in
npm_sources from JsInfo providers in data targets are included in the runfiles of the target.transitive_files from NpmPackageStoreInfo providers in data targets are also included in the runfiles of the target.When True, the —preserve-symlinks-main flag is passed to node.This prevents node from following an ESM entry script out of runfiles and the sandbox. This can happen for
.mjs
ESM entry points where the fs node patches, which guard the runfiles and sandbox, are not applied.
See https://github.com/aspect-build/rules_js/issues/362 for more information. Once #362 is resolved,
the default for this attribute can be set to False.This flag was added in Node.js v10.2.0 (released 2018-05-23). If your node toolchain is configured to use a
Node.js version older than this you’ll need to set this attribute to False.See https://nodejs.org/api/cli.html#—preserve-symlinks-main for more information.List of files to not copy to the Bazel output tree when
copy_data_to_bin is True.This is useful for exceptional cases where a copy_to_bin is not possible or not suitable for an input
file such as a file in an external repository. In most cases, this option is not needed.
See copy_data_to_bin docstring for more info.When True,
data files and the entry_point file are copied to the Bazel output tree before being passed
as inputs to runfiles.Defaults to True so that a js_binary with the default value is compatible with js_run_binary with
use_execroot_entry_point set to True, the default there.Setting this to False is more optimal in terms of inputs, but there is a yet unresolved issue of ESM imports
skirting the node fs patches and escaping the sandbox: https://github.com/aspect-build/rules_js/issues/362.
This is hit in some popular test runners such as mocha, which use native import() statements
(https://github.com/aspect-build/rules_js/pull/353). When set to False, a program such as mocha that uses ESM
imports may escape the execroot by following symlinks into the source tree. When set to True, such a program
would escape the sandbox but will end up in the output tree where node_modules and other inputs required
will be available.When True, npm is included in the runfiles of the target.An npm binary is also added on the PATH so tools can spawn npm processes. This is a bash script
on Linux and MacOS and a batch script on Windows.A minimum of rules_nodejs version 5.7.0 is required which contains the Node.js toolchain changes
to use npm.
The Node.js toolchain to use for this target.See https://bazelbuild.github.io/rules_nodejs/Toolchains.htmlTypically this is left unset so that Bazel automatically selects the right Node.js toolchain
for the target platform. See https://bazel.build/extending/toolchains#toolchain-resolution
for more information.
Function: jasmine_test
Runs jasmine under bazel test
Parameters
A unique name for this target.
Label pointing to the linked node_modules target where jasmine is linked, e.g.
//:node_modules.jasmine must be linked into the node_modules supplied.
jasmine-reporters is also required by default when jasmine_reporters is True
jasmine-core is required when using sharding.Whether
jasmine-reporters is present in the supplied node_modules tree.When enabled, adds a custom reporter to output junit XML to the path where Bazel expects to find it.jasmine config file. See: https://jasmine.github.io/setup/nodejs.html#configuration
standard attribute for tests. Defaults to “short” if both timeout and size are unspecified.
standard attribute for tests
Runtime dependencies that Jasmine should be able to read.This should include all test files, configuration files & files under test.
Additional named parameters from
js_test.
See js_test docs
