Skip to content

Commit

Permalink
feat(karma): remove ts_web_test and ts_web_test_suite rules
Browse files Browse the repository at this point in the history
BREAKING CHANGES:

The `ts_web_test` and `ts_web_test_suite` rules were duplicates of `karma_web_test` and `karma_web_test_suite` rules minus the `config_file` attribute. The `karma_web_test` and `karma_web_test_suite`, which have identical APIs, should now be used instead.
They can be loaded from `load("@npm_bazel_karma//:index.bzl", "karma_web_test")` and `load("@npm_bazel_karma//:index.bzl", "karma_web_test_suite")`.
  • Loading branch information
gregmagolan authored and alexeagle committed Nov 13, 2019
1 parent b07f65f commit 8384562
Show file tree
Hide file tree
Showing 26 changed files with 109 additions and 395 deletions.
2 changes: 1 addition & 1 deletion examples/angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ $ bazel test //e2e/...
```

In this example, there is a unit test for the `hello-world` component which uses
the `ts_web_test_suite` rule. There are also protractor e2e tests for both the
the `karma_web_test_suite` rule. There are also protractor e2e tests for both the
`prodserver` and `devserver` which use the `protractor_web_test_suite` rule.

Note that Bazel will only re-run the tests whose inputs changed since the last run.
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/src/app/hello-world/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
load("@npm_angular_bazel//:index.bzl", "ng_module")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_web_test_suite")
load("//tools:defaults.bzl", "karma_web_test_suite")

package(default_visibility = ["//:__subpackages__"])

Expand Down Expand Up @@ -52,7 +52,7 @@ ts_library(
],
)

ts_web_test_suite(
karma_web_test_suite(
name = "test",
srcs = [
# We are manaully adding the bazel generated named-UMD date-fns bundle here as
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/src/initialize_testbed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @fileoverview Provides a script to initialize TestBed before tests are run.
* This file should be included in the "runtime_deps" of a "ts_web_test_suite"
* This file should be included in the "runtime_deps" of a "karma_web_test_suite"
* rule.
*/
import {TestBed} from '@angular/core/testing';
Expand Down
8 changes: 4 additions & 4 deletions examples/angular/tools/defaults.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"Set some defaults for karma rules"

load("@npm_bazel_karma//:index.bzl", _ts_web_test_suite = "ts_web_test_suite")
load("@npm_bazel_karma//:index.bzl", _karma_web_test_suite = "karma_web_test_suite")

def ts_web_test_suite(name, browsers = [], tags = [], **kwargs):
_ts_web_test_suite(
def karma_web_test_suite(name, browsers = [], tags = [], **kwargs):
_karma_web_test_suite(
name = name,
tags = tags + ["native", "no-bazelci"],
browsers = browsers,
Expand All @@ -13,7 +13,7 @@ def ts_web_test_suite(name, browsers = [], tags = [], **kwargs):
# 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
_ts_web_test_suite(
_karma_web_test_suite(
name = "bazelci_" + name,
tags = tags + ["native", "no-circleci"],
browsers = [
Expand Down
4 changes: 2 additions & 2 deletions examples/angular_view_engine/src/app/hello-world/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
load("@npm_angular_bazel//:index.bzl", "ng_module")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
load("//tools:defaults.bzl", "ts_web_test_suite")
load("//tools:defaults.bzl", "karma_web_test_suite")

package(default_visibility = ["//:__subpackages__"])

Expand Down Expand Up @@ -52,7 +52,7 @@ ts_library(
],
)

ts_web_test_suite(
karma_web_test_suite(
name = "test",
srcs = [
# We are manaully adding the bazel generated named-UMD date-fns bundle here as
Expand Down
2 changes: 1 addition & 1 deletion examples/angular_view_engine/src/initialize_testbed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @fileoverview Provides a script to initialize TestBed before tests are run.
* This file should be included in the "runtime_deps" of a "ts_web_test_suite"
* This file should be included in the "runtime_deps" of a "karma_web_test_suite"
* rule.
*/
import {TestBed} from '@angular/core/testing';
Expand Down
8 changes: 4 additions & 4 deletions examples/angular_view_engine/tools/defaults.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"Set some defaults for karma rules"

load("@npm_bazel_karma//:index.bzl", _ts_web_test_suite = "ts_web_test_suite")
load("@npm_bazel_karma//:index.bzl", _karma_web_test_suite = "karma_web_test_suite")

def ts_web_test_suite(name, browsers = [], tags = [], **kwargs):
_ts_web_test_suite(
def karma_web_test_suite(name, browsers = [], tags = [], **kwargs):
_karma_web_test_suite(
name = name,
tags = tags + ["native", "no-bazelci"],
browsers = browsers,
Expand All @@ -13,7 +13,7 @@ def ts_web_test_suite(name, browsers = [], tags = [], **kwargs):
# 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
_ts_web_test_suite(
_karma_web_test_suite(
name = "bazelci_" + name,
tags = tags + ["native", "no-circleci"],
browsers = [
Expand Down
4 changes: 2 additions & 2 deletions examples/protocol_buffers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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_config", "ts_devserver", "ts_library")
load("//:defaults.bzl", "ts_web_test_suite")
load("//:defaults.bzl", "karma_web_test_suite")

proto_library(
name = "tire_proto",
Expand Down Expand Up @@ -45,7 +45,7 @@ ts_library(
],
)

ts_web_test_suite(
karma_web_test_suite(
name = "test",
bootstrap = ["@npm_bazel_labs//protobufjs:bootstrap_scripts"],
browsers = [
Expand Down
10 changes: 5 additions & 5 deletions examples/protocol_buffers/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Overrides for ts_web_test_suite to support bazelci testing
"""Overrides for karma_web_test_suite to support bazelci testing
"""

load("@npm_bazel_karma//:index.bzl", _ts_web_test_suite = "ts_web_test_suite")
load("@npm_bazel_karma//:index.bzl", _karma_web_test_suite = "karma_web_test_suite")

def ts_web_test_suite(name, browsers = [], tags = [], **kwargs):
def karma_web_test_suite(name, browsers = [], tags = [], **kwargs):
# 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 (disabled by rules_webtesting) and chrome do not work --- there are 0 tests to run
# TODO(gregmagolan): fix underlying issue in bazelci and remove this macro

# For CircleCI and local testing
_ts_web_test_suite(
_karma_web_test_suite(
name = name,
tags = tags + ["no-bazelci"],
browsers = browsers,
**kwargs
)

# For BazelCI mac only
_ts_web_test_suite(
_karma_web_test_suite(
name = "bazelci_chrome_" + name,
tags = tags + ["no-circleci", "no-bazelci-ubuntu", "no-bazelci-windows", "no-local"],
browsers = [
Expand Down
27 changes: 5 additions & 22 deletions examples/web_testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@npm_bazel_typescript//:index.bzl", "ts_config", "ts_library")
load("//:defaults.bzl", "karma_web_test_suite", "ts_web_test_suite")
load("//:defaults.bzl", "karma_web_test_suite")

ts_library(
name = "lib",
Expand Down Expand Up @@ -36,7 +36,7 @@ ts_library(
)

karma_web_test_suite(
name = "testing_karma",
name = "config_test",
browsers = [
"@io_bazel_rules_webtesting//browsers:chromium-local",
"@io_bazel_rules_webtesting//browsers:firefox-local",
Expand All @@ -56,24 +56,7 @@ karma_web_test_suite(
)

karma_web_test_suite(
name = "testing_karma_sauce",
browsers = [
"@io_bazel_rules_webtesting//browsers/sauce:chrome-win10",
],
tags = [
"exclusive",
"sauce",
"native",
# TODO(alexeagle): enable on CI once we have set the SAUCE env variables
"manual",
],
deps = [
":tests",
],
)

ts_web_test_suite(
name = "testing",
name = "no_config_test",
browsers = [
"@io_bazel_rules_webtesting//browsers:chromium-local",
"@io_bazel_rules_webtesting//browsers:firefox-local",
Expand All @@ -90,8 +73,8 @@ ts_web_test_suite(
],
)

ts_web_test_suite(
name = "testing_sauce",
karma_web_test_suite(
name = "sauce_test",
browsers = [
"@io_bazel_rules_webtesting//browsers/sauce:chrome-win10",
],
Expand Down
28 changes: 1 addition & 27 deletions examples/web_testing/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Overrides for karma_web_test_suite & ts_web_test_suite to support bazelci testing
"""Overrides for karma_web_test_suite to support bazelci testing
"""

load(
"@npm_bazel_karma//:index.bzl",
_karma_web_test_suite = "karma_web_test_suite",
_ts_web_test_suite = "ts_web_test_suite",
)

def ts_web_test_suite(name, browsers = [], tags = [], **kwargs):
# 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 (disabled by rules_webtesting) and chrome do not work --- there are 0 tests to run
# TODO(gregmagolan): fix underlying issue in bazelci and remove this macro

# For CircleCI and local testing
_ts_web_test_suite(
name = name,
tags = tags + ["no-bazelci"],
browsers = browsers,
**kwargs
)

# For BazelCI mac only
_ts_web_test_suite(
name = "bazelci_chrome_" + name,
tags = tags + ["no-circleci", "no-bazelci-ubuntu", "no-bazelci-windows", "no-local"],
browsers = [
"@io_bazel_rules_webtesting//browsers:chromium-local",
],
**kwargs
)

def karma_web_test_suite(name, browsers = [], tags = [], **kwargs):
# BazelCI docker images are missing shares libs to run a subset browser tests:
# mac: firefox does not work, chrome works
Expand Down
2 changes: 0 additions & 2 deletions packages/karma/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ filegroup(
"package.bzl",
"package.json",
"plugins.js",
"ts_web_test.bzl",
"web_test.bzl",
],
)

Expand Down
1 change: 1 addition & 0 deletions packages/karma/src/browser_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl", _browser_repositories = "browser_repositories")

# TODO(gregmagolan): remove this for 1.0 release
def browser_repositories():
print("""
WARNING: @npm_bazel_karma//:browser_repositories.bzl is deprecated.
Expand Down
32 changes: 25 additions & 7 deletions packages/karma/src/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,33 @@ load(
_karma_web_test = "karma_web_test",
_karma_web_test_suite = "karma_web_test_suite",
)
load(
":ts_web_test.bzl",
_ts_web_test = "ts_web_test",
_ts_web_test_suite = "ts_web_test_suite",
)

ts_web_test = _ts_web_test
ts_web_test_suite = _ts_web_test_suite
karma_web_test = _karma_web_test
karma_web_test_suite = _karma_web_test_suite
# DO NOT ADD MORE rules here unless they appear in the generated docsite.
# Run yarn skydoc to re-generate the docsite.

# TODO(gregmagolan): remove ts_web_test & ts_web_test_suite entirely for 1.0 release
def ts_web_test(**kwargs):
"""This rule has been removed. Replace with karma_web_test"""

fail("""***********
The ts_web_test rule has been removed.
The existing karma_web_test rule with an identical API should be used instead.
It can be loaded from `load("@npm_bazel_karma//:index.bzl", "karma_web_test")`.
************
""")

def ts_web_test_suite(**kwargs):
"""This rule has been removed. Replace with ts_web_test_suite"""

fail("""***********
The ts_web_test_suite rule has been removed.
The existing karma_web_test_suite rule with an identical API should be used instead.
It can be loaded from `load("@npm_bazel_karma//:index.bzl", "karma_web_test_suite")`.
************
""")
10 changes: 0 additions & 10 deletions packages/karma/src/index.from_src.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ load(
"@npm_bazel_karma//:index.bzl",
_karma_web_test = "karma_web_test",
_karma_web_test_suite = "karma_web_test_suite",
_ts_web_test = "ts_web_test",
_ts_web_test_suite = "ts_web_test_suite",
)

INTERNAL_KARMA_BIN = "@npm_bazel_karma//:karma_bin"
Expand All @@ -32,11 +30,3 @@ def karma_web_test(karma = INTERNAL_KARMA_BIN, **kwargs):
def karma_web_test_suite(karma = INTERNAL_KARMA_BIN, **kwargs):
data = kwargs.pop("data", []) + ["@npm_bazel_karma//:karma_plugins"]
_karma_web_test_suite(karma = karma, data = data, **kwargs)

def ts_web_test(karma = INTERNAL_KARMA_BIN, **kwargs):
data = kwargs.pop("data", []) + ["@npm_bazel_karma//:karma_plugins"]
_ts_web_test(karma = karma, data = data, **kwargs)

def ts_web_test_suite(karma = INTERNAL_KARMA_BIN, **kwargs):
data = kwargs.pop("data", []) + ["@npm_bazel_karma//:karma_plugins"]
_ts_web_test_suite(karma = karma, data = data, **kwargs)
Loading

0 comments on commit 8384562

Please sign in to comment.