rules_jest
v0.23.2
published 4 weeks ago
24 stars
18 forks
6 watchers
Apache License 2.0
public
4 assets
8,041 downloads
216 KB
Compatibility level 1
cPcj/LpG+vZSshPXy/1s9uT7oepq+GIz2om7Exqhodg=
v0.23.2
April 29, 2025

Using Bzlmod with Bazel 6 or greater

  1. (Bazel 6 only) Enable with common --enable_bzlmod in .bazelrc.
  2. Add to your MODULE.bazel file:
bazel_dep(name = "aspect_rules_jest", version = "0.23.2")

Using WORKSPACE

Paste this snippet into your WORKSPACE.bazel file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "aspect_rules_jest",
    sha256 = "70f723fcba46faf652b213d7cbfd6cf6e4fba1ea6af86233da89bb131aa1a1d8",
    strip_prefix = "rules_jest-0.23.2",
    url = "https://github.com/aspect-build/rules_jest/releases/download/v0.23.2/rules_jest-v0.23.2.tar.gz",
)

####################
# aspect_rules_jest setup #
####################
# Fetches the aspect_rules_jest dependencies.
# If you want to have a different version of some dependency,
# you should fetch it *before* calling this.
# Alternatively, you can skip calling this function, so long as you've
# already fetched all the dependencies.

load("@aspect_rules_jest//jest:dependencies.bzl", "rules_jest_dependencies")

rules_jest_dependencies()

load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains")

rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION)

load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

npm_translate_lock(
    name = "npm",
    npmrc = "//:.npmrc",
    pnpm_lock = "//:pnpm-lock.yaml",
    verify_node_modules_ignored = "//:.bazelignore",
)

load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()

What's Changed

Full Changelog: https://github.com/aspect-build/rules_jest/compare/v0.23.1...v0.23.2

Deps:
Assets:

Bazel rules for jest

Runs tests with the https://jestjs.io/ test runner under Bazel.

Many companies are successfully testing with rules_jest. If you're getting value from the project, please let us know! Just comment on our Adoption Discussion.

rules_jest is just a part of what Aspect provides:

Installation

From the release you wish to use: https://github.com/aspect-build/rules_jest/releases copy the WORKSPACE snippet into your WORKSPACE file.

Usage

Run all Jest tests in the workspace: bazel test --test_lang_filters=jest //...

See jest_test API documentation and the example usages in the example folder.

Note that the example also relies on code in the /WORKSPACE file in the root of this repo.

Troubleshooting and common challenges

For troubleshooting and common challenges, see docs/troubleshooting.md.