Protractor rules for Bazel
The Protractor rules run tests under the Protractor framework with Bazel.
Installation
Add the @bazel/protractor
npm package to your devDependencies
in package.json
.
protractor_web_test
USAGE
protractor_web_test(name, configuration, on_prepare, srcs, deps, data, server, tags, peer_deps,
protractor_entry_point, kwargs)
Runs a protractor test in a browser.
PARAMETERS
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 ["@build_bazel_rules_nodejs//@bazel/protractor", "@npm//protractor"]
protractor_entry_point
A label providing the protractor entry point
Default to :node_modules/protractor/bin/protractor
.
Defaults to "@npm//:node_modules/protractor/bin/protractor"
kwargs
passed through to protractor_web_test
protractor_web_test_suite
USAGE
protractor_web_test_suite(name, browsers, web_test_data, wrapped_test_tags, kwargs)
Defines a test_suite of web_test targets that wrap a protractor_web_test target.
PARAMETERS
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 wrapper 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.
3.0.0 (2020-12-22)
For a full list for the breaking changes in 3.0.0 and other notes on migrating, see the Migrating to 3.0.0 wiki page.
Bug Fixes
- builtin: only pass kwargs to the test, not the .update binary (#2361) (afa095b)
Code Refactoring
- builtin: remove node_modules attribute from nodejs_binary, nodejs_test & ts_library (c2927af)
BREAKING CHANGES
- builtin: We removed the node_modules attribute from
nodejs_binary
, nodejs_test
, jasmine_node_test
& ts_library
.
If you are using the node_modules
attribute, you can simply add the target specified there to the data
or deps
attribute of the rule instead.
For example,
nodejs_test(
name = "test",
data = [
"test.js",
"@npm//:node_modules",
],
entry_point = "test.js",
)
or
ts_library(
name = "lib",
srcs = glob(["*.ts"]),
tsconfig = ":tsconfig.json",
deps = ["@npm//:node_modules"],
)
We also dropped support for filegroup based node_modules target and removed node_modules_filegroup
from index.bzl
.
If you are using this feature for user-managed deps, you must now a js_library
target
with external_npm_package
set to True
instead.
For example,
js_library(
name = "node_modules",
srcs = glob(
include = [
"node_modules/**/*.js",
"node_modules/**/*.d.ts",
"node_modules/**/*.json",
"node_modules/.bin/*",
],
exclude = [
# Files under test & docs may contain file names that
# are not legal Bazel labels (e.g.,
# node_modules/ecstatic/test/public/中文/檔案.html)
"node_modules/**/test/**",
"node_modules/**/docs/**",
# Files with spaces in the name are not legal Bazel labels
"node_modules/**/* */**",
"node_modules/**/* *",
],
),
# Provide ExternalNpmPackageInfo which is used by downstream rules
# that use these npm dependencies
external_npm_package = True,
)
nodejs_test(
name = "test",
data = [
"test.js",
":node_modules",
],
entry_point = "test.js",
)
See examples/user_managed_deps
for a working example of user-managed npm dependencies.