mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-14 16:49:10 +00:00
chore: add jest tests, cleanup rpc
This commit is contained in:
parent
5977c35d38
commit
ac830fc946
25 changed files with 2786 additions and 319 deletions
56
hack/jest.bzl
Normal file
56
hack/jest.bzl
Normal file
|
@ -0,0 +1,56 @@
|
|||
# Copied from https://github.com/bazelbuild/rules_nodejs/blob/stable/examples/jest/jest.bzl
|
||||
# Licensed under Apache-2.0, not modified.
|
||||
|
||||
load("@npm//jest-cli:index.bzl", "jest", _jest_test = "jest_test")
|
||||
|
||||
DEFAULT_DEPS = [
|
||||
"@npm//ts-jest",
|
||||
"@npm//enzyme",
|
||||
"@npm//enzyme-adapter-react-16",
|
||||
"@npm//@types/enzyme",
|
||||
"@npm//jest-environment-enzyme",
|
||||
"@npm//jsdom",
|
||||
"@npm//jest",
|
||||
"@npm//jest-enzyme",
|
||||
"@npm//jest-styled-components",
|
||||
"@npm//enzyme-to-json",
|
||||
"@npm//react-dom",
|
||||
"@npm//@types/react-dom",
|
||||
"//:tsconfig.json",
|
||||
]
|
||||
|
||||
def _impl_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", "$(rootpath %s)" % src])
|
||||
|
||||
data = [jest_config] + srcs + deps + ["//:jest-reporter.js"]
|
||||
_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
|
||||
)
|
||||
|
||||
def jest_test(src, deps = []):
|
||||
_impl_jest_test(
|
||||
name = src[1:] + "_test",
|
||||
srcs = native.glob(["*.spec.ts", "*.spec.tsx"]),
|
||||
deps = [src] + deps + DEFAULT_DEPS,
|
||||
jest_config = "//:jest.config.js",
|
||||
)
|
|
@ -3,9 +3,17 @@ load("@npm//@bazel/typescript:index.bzl", "ts_library")
|
|||
def _render_deps(deps = []):
|
||||
output_deps = []
|
||||
|
||||
has_added_grpc_deps = False
|
||||
|
||||
for dep in deps:
|
||||
if dep.startswith("//src/rpc"):
|
||||
output_deps.append(dep + ":ts")
|
||||
if has_added_grpc_deps == False:
|
||||
output_deps.extend([
|
||||
"@npm//google-protobuf",
|
||||
"@npm//@improbable-eng/grpc-web",
|
||||
])
|
||||
has_added_grpc_deps = True
|
||||
elif dep.startswith("//"):
|
||||
output_deps.append(dep)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue