blob: 01a23c66756aab784592ac98174999b8cc446246 [file]
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
load("@npm//http-server:index.bzl", "http_server")
load("@npm//typescript:index.bzl", "tsc")
load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite")
load("@npm_bazel_rollup//:index.bzl", "rollup_bundle")
load("@npm_bazel_terser//:index.bzl", "terser_minified")
load("@npm_bazel_typescript//:index.bzl", "ts_devserver", "ts_library")
package(default_visibility = ["//visibility:public"])
ts_library(
name = "app",
srcs = ["app.ts"],
)
ts_devserver(
name = "devserver",
index_html = "index.html",
# We'll collect all the devmode JS sources from these TypeScript libraries
deps = [":app"],
)
rollup_bundle(
name = "bundle",
entry_point = ":app.ts",
deps = [":app"],
)
terser_minified(
name = "bundle.min",
src = ":bundle",
)
web_package(
name = "package",
assets = [
":bundle.min",
"//styles:base.css",
"//styles:test.css",
],
index_html = "index.html",
)
http_server(
name = "prodserver",
data = [":package"],
templated_args = ["package"],
)
# we could use ts_library here, but we use plain typescript to demonstrate that it works
tsc(
name = "e2e",
testonly = 1,
# Remember that Bazel requires it know what outputs are created ahead of time
# so that it can construct a dependency graph.
outs = [
"app.e2e-spec.js",
],
args = [
"-p",
"$(location tsconfig-test.json)",
"--outDir",
# $@ is a shorthand for the dist/bin directory where Bazel requires we write outputs
"$@",
],
data = [
"app.e2e-spec.ts",
"tsconfig.json",
"tsconfig-test.json",
"@npm//@types/jasmine",
"@npm//@types/node",
"@npm//protractor",
],
)
# BazelCI docker images are missing shares libs to run a subset browser tests:
# mac: firefox does not work, chrome works
# ubuntu: firefox and chrome do not work --- there are 0 tests to run
# windows: firefox works, chrome does not work
# TODO(gregmagolan): support firefox in protractor rule
protractor_web_test_suite(
name = "prodserver_test",
on_prepare = ":protractor.on-prepare.js",
server = "//:prodserver",
tags = [
"no-bazelci-ubuntu",
"no-bazelci-windows",
],
deps = [":e2e"],
)
# BazelCI docker images are missing shares libs to run a subset browser tests:
# mac: firefox does not work, chrome works
# ubuntu: firefox and chrome do not work --- there are 0 tests to run
# windows: firefox works, chrome does not work
# TODO(gregmagolan): support firefox in protractor rule
protractor_web_test_suite(
name = "devserver_test",
on_prepare = ":protractor.on-prepare.js",
server = "//:devserver",
tags = [
"no-bazelci-ubuntu",
"no-bazelci-windows",
],
deps = [":e2e"],
)
# Just a dummy test so that we have a test target for //... on certain bazelci platforms with bazel_integration_test
sh_test(
name = "dummy_test",
srcs = ["dummy_test.sh"],
)