Protractor rules for Bazel
WARNING: this is beta-quality software. Breaking changes are likely. Not recommended for production use without expert support.
The Protractor rules run tests under the Protractor framework with Bazel.
Installation
Add the @bazel/protractor
npm package to your devDependencies
in package.json
.
Your WORKSPACE
should declare a yarn_install
or npm_install
rule named npm
.
It should then install the rules found in the npm packages using the `install_bazel_dependencies' function.
See https://github.com/bazelbuild/rules_nodejs/#quickstart
This causes the @bazel/protractor
package to be installed as a Bazel workspace named npm_bazel_protractor
.
protractor_web_test
Runs a protractor test in a browser.
Usage
protractor_web_test(name, configuration, on_prepare, srcs, deps, data, server, tags, peer_deps, protractor_entry_point, kwargs)
name
The name of the test
configuration
Protractor configuration file.
Defaults to None
on_prepare
A file with a node.js script to run once before all tests run.
If the script exports a function which returns a promise, protractor
will wait for the promise to resolve before beginning tests.
Defaults to None
srcs
JavaScript source files
Defaults to []
deps
Other targets which produce JavaScript such as ts_library
Defaults to []
data
Runtime dependencies
Defaults to []
server
Optional server executable target
Defaults to None
tags
Standard Bazel tags, this macro adds one for ibazel
Defaults to []
peer_deps
List of peer npm deps required by protractor_web_test.
Defaults to ["@npm//@bazel/protractor", "@npm//protractor"]
protractor_entry_point
A label providing the @npm//protractor entry point.
Default to @npm//:node_modules/protractor/bin/protractor
.
Defaults to "@npm//:node_modules/protractor/bin/protractor"
kwargs
passed through to protractor_web_test
protractor_web_test_suite
Defines a test_suite of web_test targets that wrap a protractor_web_test target.
Usage
protractor_web_test_suite(name, browsers, web_test_data, wrapped_test_tags, kwargs)
name
The base name of the test
browsers
A sequence of labels specifying the browsers to use.
Defaults to None
web_test_data
Data dependencies for the wrapoer web_test targets.
Defaults to []
wrapped_test_tags
A list of test tag strings to use for the wrapped
karma_web_test target.
Defaults to ["manual", "noci"]
kwargs
Arguments for the wrapped karma_web_test target.
0.41.0 (2019-11-22)
To upgrade:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "8dc1466f8563f3aa4ac7ab7aa3c96651eb7764108219f40b2d1c918e1a81c601",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.41.0/rules_nodejs-0.41.0.tar.gz"],
)
and run yarn upgrade --scope @bazel
to update all your @bazel
-scoped npm packages to the latest versions.
(or manually do the npm equivalent - they don't have a way to update a scope)
BREAKING CHANGES
As mentioned before, we are close to a 1.0 release, so we are making all our breaking changes now to prepare for a period of stability. Sorry for the long list this time!
web_package
rule has been renamed to pkg_web
and is now a public API
Update your load statements from
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
to
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web")
ts_devserver
and pkg_web
(previously web_package
) no longer have an index_html
attribute.
They expect an index.html file to be among the assets, and to already
have the script and link tags needed for the app to work.
The feature where those tags were injected into the html dynamically has
been moved to its own rule, inject_html.
We are in a transition state where the inject_html
rule is not published, because we want this to be a plain npm package and not Bazel-specific. We will publish this functionality soon. If you depend on it, you may want to delay this upgrade.
-
internal/rollup_bundle rule is removed. see https://github.com/bazelbuild/rules_nodejs/wiki for migration instructions
-
Removed the expand_location_into_runfiles helper from //internal:node.bzl
Load it from //internal/common:expand_into_runfiles instead
-
npm karma deps for karma_web_test and karma_web_suite are now peer deps so that the versions used can be chosen by the user.
This PR also removes the built-in @io_bazel_rules_webtesting//browsers/sauce:chrome-win10
saucelabs support. It is not very useful as it only tests a single browser and it difficult to use. In the angular repo, saucelabs support was implemented with a custom karma config using karma_web_test. This is the recommended approach.
bazel run @nodejs//:npm
is replaced with bazel run @nodejs//:npm_node_repositories
and bazel run @nodejs//:yarn
is replaced with bazel run @nodejs//:yarn_node_repositories
. @nodejs//:yarn
and @nodejs//:npm
now run yarn & npm in the current working directory instead of on all of the package.json
files in node_repositories()
.
@nodejs//:bin/node
& @nodejs//:bin/node.cmd
(on Windows) are no longer valid targets. Use @nodejs//:node
instead on all platforms. You can still call the old targets in their platform specific node repositories such as @nodejs_darwin_amd64//:bin/node
.
@nodejs//:bin/yarn
& @nodejs//:bin/yarn.cmd
(on Windows) are no longer valid targets. Use @nodejs//:yarn
instead on all platforms. You can still call the old targets in their platform specific node repositories such as @nodejs_darwin_amd64//:bin/yarn
.
@nodejs//:bin/npm
& @nodejs//:bin/npm.cmd
(on Windows) are no longer valid targets. Use @nodejs//:npm
instead on all platforms. You can still call the old targets in their platform specific node repositories such as @nodejs_darwin_amd64//:bin/npm
.
Bug Fixes
- builtin: allow .tsx entry_point in node binary/test (313d484), closes #1351
- terser: call terser binary instead of uglifyjs (#1360) (a100420)
- terser: remove ngDevMode & ngI18nClosureMode global_defs from default terser config (98c8dbc)
chore
Code Refactoring
- move injector feature to own rule (be06d23)
Features
- node-patches\filesystem patcher. (#1332) (0b2f675)
- support --compilation_mode flag (9fa4343)
- builtin: rename @nodejs//:npm and @nodejs//:yarn to @nodejs//:[yarn/npm]_node_repositories (#1369) (01079a3)
- karma: npm peer deps & remove @rules_webtesting//browsers/sauce:chrome-win10 support (318bbf3)
- protractor: protractor npm package is now a peer deps (#1352) (5db7c8e)