mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
add macro for invoking Jest
This commit is contained in:
parent
c3fc07ac20
commit
d158450e89
4 changed files with 48 additions and 83 deletions
|
@ -5,7 +5,7 @@ load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte", "svelte_check")
|
|||
load("//ts:esbuild.bzl", "esbuild")
|
||||
load("//ts:vendor.bzl", "copy_bootstrap_icons")
|
||||
load("//ts:compile_sass.bzl", "compile_sass")
|
||||
load("@npm//jest-cli:index.bzl", "jest_test")
|
||||
load("//ts:jest.bzl", "jest_test")
|
||||
|
||||
compile_sass(
|
||||
srcs = ["deckconfig-base.scss"],
|
||||
|
@ -125,35 +125,12 @@ svelte_check(
|
|||
],
|
||||
)
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
srcs = glob(["*.test.ts"]),
|
||||
tsconfig = "//ts:tsconfig.json",
|
||||
jest_test(
|
||||
data = [
|
||||
"@npm//protobufjs",
|
||||
],
|
||||
deps = [
|
||||
":lib",
|
||||
"//ts/lib:backend_proto",
|
||||
"@npm//@types/jest",
|
||||
],
|
||||
)
|
||||
|
||||
jest_test(
|
||||
name = "test",
|
||||
args = [
|
||||
"--no-cache",
|
||||
"--no-watchman",
|
||||
"--ci",
|
||||
"--colors",
|
||||
"--config",
|
||||
"$(location //ts:jest.config.js)",
|
||||
],
|
||||
data = [
|
||||
":test_lib",
|
||||
"//ts:jest.config.js",
|
||||
"@npm//protobufjs",
|
||||
],
|
||||
target_compatible_with = select({
|
||||
"@platforms//os:osx": [],
|
||||
"@platforms//os:linux": [],
|
||||
"//conditions:default": ["@platforms//os:linux"],
|
||||
}),
|
||||
)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_library")
|
||||
load("@npm//jest-cli:index.bzl", "jest_test")
|
||||
load("//ts:jest.bzl", "jest_test")
|
||||
load("//ts:prettier.bzl", "prettier_test")
|
||||
load("//ts:eslint.bzl", "eslint_test")
|
||||
|
||||
|
@ -15,38 +15,12 @@ ts_library(
|
|||
deps = [],
|
||||
)
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
srcs = glob(["*.test.ts"]),
|
||||
tsconfig = "//ts:tsconfig.json",
|
||||
jest_test(
|
||||
deps = [
|
||||
"html-filter",
|
||||
"@npm//@types/jest",
|
||||
],
|
||||
)
|
||||
|
||||
jest_test(
|
||||
name = "test",
|
||||
args = [
|
||||
"--no-cache",
|
||||
"--no-watchman",
|
||||
"--ci",
|
||||
"--colors",
|
||||
"--config",
|
||||
"$(location //ts:jest.config.js)",
|
||||
],
|
||||
data = [
|
||||
":test_lib",
|
||||
"//ts:jest.config.js",
|
||||
"//ts:package.json",
|
||||
],
|
||||
target_compatible_with = select({
|
||||
"@platforms//os:osx": [],
|
||||
"@platforms//os:linux": [],
|
||||
"//conditions:default": ["@platforms//os:linux"],
|
||||
}),
|
||||
)
|
||||
|
||||
# Tests
|
||||
################
|
||||
|
||||
|
|
37
ts/jest.bzl
Normal file
37
ts/jest.bzl
Normal file
|
@ -0,0 +1,37 @@
|
|||
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"],
|
||||
}),
|
||||
)
|
|
@ -2,7 +2,7 @@ load("@npm//@bazel/typescript:index.bzl", "ts_library")
|
|||
load("//ts:prettier.bzl", "prettier_test")
|
||||
load("//ts:eslint.bzl", "eslint_test")
|
||||
load("//ts:protobuf.bzl", "protobufjs_library")
|
||||
load("@npm//jest-cli:index.bzl", "jest_test")
|
||||
load("//ts:jest.bzl", "jest_test")
|
||||
|
||||
# Protobuf
|
||||
#############
|
||||
|
@ -77,34 +77,11 @@ eslint_test(
|
|||
srcs = glob(["*.ts"]),
|
||||
)
|
||||
|
||||
ts_library(
|
||||
name = "test_lib",
|
||||
srcs = glob(["*.test.ts"]),
|
||||
tsconfig = "//ts:tsconfig.json",
|
||||
deps = [
|
||||
":lib",
|
||||
"@npm//@types/jest",
|
||||
],
|
||||
)
|
||||
|
||||
jest_test(
|
||||
name = "test",
|
||||
args = [
|
||||
"--no-cache",
|
||||
"--no-watchman",
|
||||
"--ci",
|
||||
"--colors",
|
||||
"--config",
|
||||
"$(location //ts:jest.config.js)",
|
||||
],
|
||||
data = [
|
||||
":test_lib",
|
||||
"//ts:jest.config.js",
|
||||
"@npm//protobufjs",
|
||||
],
|
||||
target_compatible_with = select({
|
||||
"@platforms//os:osx": [],
|
||||
"@platforms//os:linux": [],
|
||||
"//conditions:default": ["@platforms//os:linux"],
|
||||
}),
|
||||
deps = [
|
||||
":lib",
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue