anki/ts/jest.bzl

38 lines
1006 B
Python
Raw Normal View History

2021-04-16 15:46:31 +02:00
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("@npm//jest-cli:index.bzl", _jest_test = "jest_test")
def jest_test(deps, data = [], name = "jest"):
"Build *.test.ts into a library, then test it with Jest."
# compile sources
ts_library(
name = name + "_lib",
srcs = native.glob(["*.test.ts"]),
tsconfig = "//ts:tsconfig.json",
deps = deps + [
"@npm//@types/jest",
],
)
# then test them
_jest_test(
name = name,
args = [
"--no-cache",
"--no-watchman",
"--ci",
"--colors",
"--config",
"$(location //ts:jest.config.js)",
],
data = data + [
name + "_lib",
"//ts:jest.config.js",
],
target_compatible_with = select({
"@platforms//os:osx": [],
"@platforms//os:linux": [],
"//conditions:default": ["@platforms//os:linux"],
}),
)