Skip to content

Commit

Permalink
Fix issue with jest not supporting symlinks
Browse files Browse the repository at this point in the history
This adds jest.bzl and uses it to pass in specific tests.

See jestjs/jest#7549
  • Loading branch information
mc0 committed Dec 10, 2020
1 parent bc7a7a6 commit ef43c7a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
29 changes: 29 additions & 0 deletions jest.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
load("@npm//jest-cli:index.bzl", "jest", _jest_test = "jest_test")

def jest_test(name, srcs, deps, jest_config, **kwargs):
"A macro around the autogenerated jest_test rule"
templated_args = [
"--no-cache",
"--no-watchman",
"--ci",
"--colors",
]
templated_args.extend(["--config", "$(rootpath %s)" % jest_config])
for src in srcs:
templated_args.extend(["--runTestsByPath", "$(rootpaths %s)" % src])

data = [jest_config] + srcs + deps
_jest_test(
name = name,
data = data,
templated_args = templated_args,
**kwargs
)

# This rule is used specifically to update snapshots via `bazel run`
jest(
name = "%s.update" % name,
data = data,
templated_args = templated_args + ["-u"],
**kwargs
)
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
reporters: ['default'],
testEnvironment: 'node',
testMatch: ['**/*.test.js'],
};
19 changes: 4 additions & 15 deletions ts/lib/greet/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@npm//jest-cli:index.bzl", "jest_test")
load("//:jest.bzl", "jest_test")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -28,18 +28,7 @@ js_library(

jest_test(
name = "ts_greet_test",
args = [
"--no-cache",
"--no-watchman",
"--ci",
"--colors",
"--config",
"jest.config.js",
],
data = [
":greet",
":package.json",
":tsconfig-greet",
"//:jest.config.js",
],
srcs = [":tsconfig"],
jest_config = "//:jest.config.js",
deps = [],
)

0 comments on commit ef43c7a

Please sign in to comment.