2019-08-15 11:35:33 -04:00
|
|
|
load("//tools:defaults.bzl", "rollup_bundle", "ts_library")
|
2019-07-21 06:44:13 -04:00
|
|
|
load("@npm_bazel_karma//:index.bzl", "karma_web_test_suite")
|
|
|
|
|
|
|
|
def karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps, test_entry_point):
|
|
|
|
ts_library(
|
|
|
|
name = name + "_env",
|
|
|
|
testonly = True,
|
|
|
|
srcs = env_srcs,
|
|
|
|
deps = env_deps,
|
|
|
|
)
|
|
|
|
rollup_bundle(
|
|
|
|
name = name + "_env_rollup",
|
|
|
|
testonly = True,
|
2019-12-21 20:27:41 -05:00
|
|
|
sourcemap = "false",
|
2019-07-21 06:44:13 -04:00
|
|
|
entry_point = env_entry_point,
|
2020-03-05 16:53:34 -05:00
|
|
|
silent = True,
|
2019-07-21 06:44:13 -04:00
|
|
|
deps = [
|
|
|
|
":" + name + "_env",
|
2019-10-27 19:28:03 -04:00
|
|
|
"@npm//rollup-plugin-commonjs",
|
|
|
|
"@npm//rollup-plugin-node-resolve",
|
2019-07-21 06:44:13 -04:00
|
|
|
],
|
|
|
|
)
|
|
|
|
ts_library(
|
|
|
|
name = name + "_test",
|
|
|
|
testonly = True,
|
|
|
|
srcs = test_srcs,
|
|
|
|
deps = test_deps,
|
|
|
|
)
|
|
|
|
rollup_bundle(
|
|
|
|
name = name + "_rollup",
|
|
|
|
testonly = True,
|
2020-03-05 16:53:34 -05:00
|
|
|
silent = True,
|
2019-12-21 20:27:41 -05:00
|
|
|
sourcemap = "false",
|
2019-07-21 06:44:13 -04:00
|
|
|
entry_point = test_entry_point,
|
2019-10-27 19:28:03 -04:00
|
|
|
config_file = "//packages/zone.js:rollup-es5.config.js",
|
2019-07-21 06:44:13 -04:00
|
|
|
deps = [
|
|
|
|
":" + name + "_test",
|
2019-10-27 19:28:03 -04:00
|
|
|
"@npm//rollup-plugin-commonjs",
|
|
|
|
"@npm//rollup-plugin-node-resolve",
|
2019-07-21 06:44:13 -04:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
def karma_test(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps, test_entry_point, bootstraps, ci):
|
|
|
|
first = True
|
|
|
|
for subname in bootstraps:
|
|
|
|
bootstrap = bootstraps[subname]
|
|
|
|
firstFlag = first
|
|
|
|
if first:
|
|
|
|
first = False
|
|
|
|
karma_test_prepare(name, env_srcs, env_deps, env_entry_point, test_srcs, test_deps, test_entry_point)
|
|
|
|
_karma_test_required_dist_files = [
|
2019-12-21 20:27:41 -05:00
|
|
|
"//packages/zone.js/dist:task-tracking.js",
|
|
|
|
"//packages/zone.js/dist:wtf.js",
|
|
|
|
"//packages/zone.js/dist:webapis-notification.js",
|
|
|
|
"//packages/zone.js/dist:webapis-media-query.js",
|
|
|
|
"//packages/zone.js/dist:zone-patch-canvas.js",
|
|
|
|
"//packages/zone.js/dist:zone-patch-fetch.js",
|
|
|
|
"//packages/zone.js/dist:zone-patch-resize-observer.js",
|
2020-03-11 19:38:37 -04:00
|
|
|
"//packages/zone.js/dist:zone-patch-message-port.js",
|
2019-12-21 20:27:41 -05:00
|
|
|
"//packages/zone.js/dist:zone-patch-user-media.js",
|
|
|
|
":" + name + "_rollup.umd",
|
2019-07-21 06:44:13 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
karma_web_test_suite(
|
|
|
|
name = subname + "_karma_jasmine_test",
|
|
|
|
srcs = [
|
|
|
|
"fake_entry.js",
|
|
|
|
],
|
|
|
|
bootstrap = [
|
2019-12-21 20:27:41 -05:00
|
|
|
":" + name + "_env_rollup.umd",
|
2019-07-21 06:44:13 -04:00
|
|
|
] + bootstrap +
|
|
|
|
_karma_test_required_dist_files,
|
2020-04-24 13:26:36 -04:00
|
|
|
browsers = ["//tools/browsers:chromium"],
|
2019-07-21 06:44:13 -04:00
|
|
|
static_files = [
|
|
|
|
":assets/sample.json",
|
|
|
|
":assets/worker.js",
|
|
|
|
":assets/import.html",
|
|
|
|
],
|
|
|
|
tags = ["zone_karma_test"],
|
|
|
|
runtime_deps = [
|
|
|
|
"@npm//karma-browserstack-launcher",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
if ci and firstFlag:
|
|
|
|
karma_web_test_suite(
|
|
|
|
name = "karma_jasmine_test_ci",
|
|
|
|
srcs = [
|
|
|
|
"fake_entry.js",
|
|
|
|
],
|
|
|
|
bootstrap = [
|
|
|
|
":saucelabs.js",
|
2019-12-21 20:27:41 -05:00
|
|
|
":" + name + "_env_rollup.umd",
|
|
|
|
"//packages/zone.js/dist:zone-testing-bundle.min.js",
|
2019-07-21 06:44:13 -04:00
|
|
|
] + _karma_test_required_dist_files,
|
2020-04-24 13:26:36 -04:00
|
|
|
browsers = ["//tools/browsers:chromium"],
|
2019-07-21 06:44:13 -04:00
|
|
|
config_file = "//:karma-js.conf.js",
|
|
|
|
configuration_env_vars = ["KARMA_WEB_TEST_MODE"],
|
|
|
|
data = [
|
|
|
|
"//:browser-providers.conf.js",
|
|
|
|
"//tools:jasmine-seed-generator.js",
|
|
|
|
],
|
|
|
|
static_files = [
|
|
|
|
":assets/sample.json",
|
|
|
|
":assets/worker.js",
|
|
|
|
":assets/import.html",
|
|
|
|
],
|
|
|
|
tags = ["zone_karma_test"],
|
2019-12-06 10:17:09 -05:00
|
|
|
# Visible to //:saucelabs_unit_tests_poc target
|
2019-07-21 06:44:13 -04:00
|
|
|
visibility = ["//:__pkg__"],
|
|
|
|
runtime_deps = [
|
|
|
|
"@npm//karma-browserstack-launcher",
|
|
|
|
],
|
|
|
|
)
|