tree: 511eb60e1c0ec52e8c7157b405ee513bcd923590
  1. __snapshots__/
  2. patches/
  3. ts/
  4. .bazelignore
  5. .bazelrc
  6. babel.config.js
  7. BUILD.bazel
  8. dummy_test.sh
  9. extra.js
  10. index.js
  11. index.test.js
  12. index2.test.js
  13. jest-reporter.js
  14. jest.bzl
  15. jest.config.js
  16. jest.ts.config.js
  17. package.json
  18. README.md
  19. tsconfig.json
  20. WORKSPACE
  21. yarn.lock
examples/jest/README.md

Jest example

This example shows how you might use the Jest testing framework

It has a utility macro in jest.bzl which makes a more ergonomic API for calling the jest_test rule in @npm//jest-cli:index.bzl. We suggest copying that to your repo.

Running on Windows

To make the tests running on windows as well you have to add the --enable_runfiles flag to your .bazelrc. This requires running under elevated privileges (Admin rights), Windows 10 Creators Update (1703) or later system version, and enabling developer mode.

build --enable_runfiles
run --enable_runfiles
test --enable_runfiles

Jest typescript example

Under ts/ there's an example of using jest with typescript directly with generated rule from @npm//jest-cli:index.bzl