aspect-build / aspect-build/rules_jest
[Bug]: jest_tests report PASS when they fail with FATAL error due to BAZEL_BINDIR unset
- Dominant language
- Starlark
- Stars
- 24
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
### What happened?
On Windows, if BAZEL_BINDIR isn't set, tests are reported to pass but actually fail:
```
> bazel test //src/project/... --test_output=all
INFO: Writing tracer profile to 'D:/udu/b/23nyshzg/command.profile.gz'
INFO: Invocation ID: 687413ac-8a48-4046-8fed-78f520b63921
INFO: Analyzed target //src/project:test (1 packages loaded, 97 targets configured).
INFO: From Testing //src/project:test:
==================== Test output for //src/project:test:
FATAL: aspect_rules_jest[jest_test]:
BAZEL_BINDIR must be set in environment to the makevar $(BINDIR) in js_binary build actions (which run in the execroot) so that build actions can change directories to always run out of the root of the Bazel output tree. See https://docs.bazel.build/versions/main/be/make-variables.html#predefined_variables. This is automatically set by 'js_run_binary' (https://github.com/aspect-build/rules_js/blob/main/docs/js_run_binary.md) which is the recommended rule to use for using a js_binary as the tool of a build action. If this is not a build action you can set the BAZEL_BINDIR to '.' instead to suppress this error. For more context on this design decision, please read the aspect_rules_js README https://github.com/aspect-build/rules_js/tree/dbb5af0d2a9a2bb50e4cf4a96dbc582b27567155#running-nodejs-programs.
================================================================================
INFO: Found 1 test target...
Target //src/project:test up-to-date:
bazel-bin/src/project/test_/test.bat
INFO: Elapsed time: 1.781s, Critical Path: 1.13s
INFO: 28 processes: 1 remote cache hit, 26 internal, 1 local.
INFO: Build completed successfully, 28 total actions
//src/project:test PASSED in 0.4s
```
A workaround is to add BAZEL_BINDIR as env to the jest_test:
```
env = {
"BAZEL_BINDIR": ".",
},
```
There are two issues:
1. Fatal errors should not be reported as a PASS
2. BAZEL_BINDIR should not be required to be set
### Version
Development (host) and target OS/architectures:
Windows
Output of `bazel --version`:
7.6.1
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
rules_js 2.4.2
rules_jest 0.23.3
Language(s) and/or frameworks involved:
### How to reproduce
```shell
```
### Any other information?
_No response_
Contributor guide
Research direction
Start with the jest_test rule and the Bazel test execution path in rules_jest 0.23.3, using the Windows output and the BAZEL_BINDIR env workaround as the reproducer. Check how the reported FATAL error affects the test result and whether BAZEL_BINDIR is unnecessarily required. Done means the failure is reported as failed and the rule works without manually setting that environment variable.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100