angular/tools/testing/BUILD.bazel
Paul Gschwendtner 57a0499529 build: bundle tests for karma web test suites (#48521)
Since Karma with Bazel does not support ESM natively, we bundle the
tests using ESBuild into a single AMD file. This not only solves the
ESM issue until we can run browser ESM tests natively (also pending
in the components repo - the esbuild generation follows ESM semantics
but since collapsed we don't rely on the real module system).

A benefit of bundling is also faster and more reliable Karma browser
tests since only a single file needs to be loaded- compared to hundreds
of individual files.

PR Close #48521
2022-12-19 19:50:42 +00:00

74 lines
1.9 KiB
Text

load("//tools:defaults.bzl", "jasmine_node_test", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "zone_base_setup_lib",
testonly = 1,
srcs = ["zone_base_setup.ts"],
deps = [
"//packages/zone.js/lib",
],
)
ts_library(
name = "browser",
testonly = 1,
srcs = ["browser_tests.init.ts"],
deps = [
":zone_base_setup_lib",
"//packages/compiler",
"//packages/core/testing",
"//packages/platform-browser-dynamic/testing",
"//packages/platform-browser/animations",
"//packages/zone.js/lib",
],
)
ts_library(
name = "node",
testonly = 1,
srcs = ["node_tests.init.ts"],
deps = [
":zone_base_setup_lib",
"//packages/compiler",
"//packages/core/testing",
"//packages/platform-server",
"//packages/platform-server/testing",
"//packages/zone.js/lib",
"@npm//domino",
],
)
ts_library(
name = "node_no_angular",
testonly = 1,
srcs = ["node_no_angular_tests.init.ts"],
deps = [
"//packages:types",
],
)
# A test to verify that jasmine_node_test targets fail as expected.
# This is to catch any future regressions to jasmine_node_test where
# tests pass silently without executing.
# See https://github.com/bazelbuild/rules_nodejs/pull/1540 for an example
# of a potential regression.
jasmine_node_test(
name = "fail_test",
srcs = ["fail.spec.js"],
expected_exit_code = 55,
)
# A test to verify that jasmine_node_test targets fail as expected
# when there is a bootstrap script set.
# This is to catch any future regressions to jasmine_node_test where
# tests pass silently without executing.
# See https://github.com/bazelbuild/rules_nodejs/pull/1540 for an example
# of a potential regression.
jasmine_node_test(
name = "fail_bootstrap_test",
srcs = ["fail.spec.js"],
bootstrap = ["//tools/testing:node"],
expected_exit_code = 55,
)