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.42.1 (2019-11-27)
To upgrade:
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "c612d6b76eaa17540e8b8c806e02701ed38891460f9ba3303f4424615437887a",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.42.1/rules_nodejs-0.42.1.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)
New stuff
In 0.41.0 we noted that a feature for inserting <script>
and <link>
tags was dropped from ts_devserver
and pkg_web
but the replacement wasn't available. Now it is thanks to @jbedard who published a standalone npm package html-insert-assets
. You can see how it's wired in the examples.
If you waited to upgrade before, now you should.
Bug Fixes
- @npm//foobar:foobar__files target no longer includes nested node_modules (#1390) (a13f2b6)
- allow files in protractor data attribute (3feb13c)
- builtin: $(RULEDIR) npm_package_bin expansion should always be the root output directory (b494974)
- builtin: locations arg of npm_package_bin should result in separate argv (242379f)
- builtin: use correct genrule-style make vars (77039b1)
- examples: kotlin example server working (adf6934)
BREAKING CHANGES
- builtin: We fixed
npm_package_bin
and all rules generated by it, to match genrule behavior as documented at https://docs.bazel.build/versions/master/be/make-variables.html#predefined_genrule_variables
This means that usage of the $@
shortcut to refer to the output directory should now be $(@D)
when output_dir=True
and you can now use $@
to refer to the location of a single output