-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.bzl
45 lines (36 loc) · 1.09 KB
/
test.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("@npm//jest-cli:index.bzl", _jest_test = "jest_test")
def ts_test(name, srcs, deps, data = [], jest_config = "//:jest.config.js", **kwargs):
"A macro around the autogenerated jest_test rule, by the incomparable @spacerat"
lib_name = name + "_lib"
src_name = name + "_src"
deps = deps + [
"@npm//@aws-cdk/assert",
"@npm//@types/jest",
]
# Compile the test and extract its js files
ts_library(
name = lib_name,
srcs = srcs,
deps = deps,
)
native.filegroup(
name = src_name,
srcs = [":" + lib_name],
output_group = "es5_sources",
)
src_label = ":" + src_name
# Run the test
args = [
"--no-cache",
"--no-watchman",
"--ci",
]
args.extend(["--config", "$(rootpath %s)" % jest_config])
args.extend(["--runTestsByPath", "$(rootpaths %s)" % src_label])
_jest_test(
name = name,
data = [jest_config, src_label] + deps + data,
templated_args = args,
**kwargs
)