mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Allow passing debug=True to jest_test for debugger support (#2013)
This commit is contained in:
parent
9ca13ca3bc
commit
ea53c73bf2
1 changed files with 10 additions and 3 deletions
13
ts/jest.bzl
13
ts/jest.bzl
|
@ -1,7 +1,7 @@
|
||||||
load("@npm//@bazel/esbuild:index.bzl", "esbuild")
|
load("@npm//@bazel/esbuild:index.bzl", "esbuild")
|
||||||
load("@npm//jest-cli:index.bzl", _jest_test = "jest_test")
|
load("@npm//jest-cli:index.bzl", _jest_test = "jest_test")
|
||||||
|
|
||||||
def jest_test(deps, name = "jest", protobuf = False, env = "node"):
|
def jest_test(deps, name = "jest", protobuf = False, env = "node", debug = False):
|
||||||
ts_sources = native.glob(["**/*.test.ts"])
|
ts_sources = native.glob(["**/*.test.ts"])
|
||||||
|
|
||||||
# bundle each test file up with its dependencies for jest
|
# bundle each test file up with its dependencies for jest
|
||||||
|
@ -30,7 +30,7 @@ def jest_test(deps, name = "jest", protobuf = False, env = "node"):
|
||||||
srcs = esbuild_extra_srcs,
|
srcs = esbuild_extra_srcs,
|
||||||
deps = deps,
|
deps = deps,
|
||||||
# the code shaking saves close to a second off the deckoptions/lib.test.ts test
|
# the code shaking saves close to a second off the deckoptions/lib.test.ts test
|
||||||
minify = True,
|
minify = not debug,
|
||||||
target_compatible_with = select({
|
target_compatible_with = select({
|
||||||
"@platforms//os:osx": [],
|
"@platforms//os:osx": [],
|
||||||
"@platforms//os:linux": [],
|
"@platforms//os:linux": [],
|
||||||
|
@ -43,6 +43,13 @@ def jest_test(deps, name = "jest", protobuf = False, env = "node"):
|
||||||
"@npm//jest-environment-jsdom",
|
"@npm//jest-environment-jsdom",
|
||||||
] if env == "jsdom" else []
|
] if env == "jsdom" else []
|
||||||
|
|
||||||
|
# After starting Jest, open the url "chrome://inspect" in
|
||||||
|
# a Chrome browser and inspect as remote target.
|
||||||
|
debug_args = [
|
||||||
|
"--run-in-band",
|
||||||
|
"--node_options=--inspect-brk",
|
||||||
|
] if debug else []
|
||||||
|
|
||||||
_jest_test(
|
_jest_test(
|
||||||
name = name,
|
name = name,
|
||||||
args = [
|
args = [
|
||||||
|
@ -53,7 +60,7 @@ def jest_test(deps, name = "jest", protobuf = False, env = "node"):
|
||||||
"--config",
|
"--config",
|
||||||
"$(location //ts:jest.config.js)",
|
"$(location //ts:jest.config.js)",
|
||||||
"--env=" + env,
|
"--env=" + env,
|
||||||
],
|
] + debug_args,
|
||||||
data = deps + bundled_srcs + [
|
data = deps + bundled_srcs + [
|
||||||
"//ts:jest.config.js",
|
"//ts:jest.config.js",
|
||||||
] + optional_jsdom_deps,
|
] + optional_jsdom_deps,
|
||||||
|
|
Loading…
Reference in a new issue