Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 35fbffb

Browse files
committed
Switch to protractor_web_test_suite for e2e tests
1 parent 43c3f56 commit 35fbffb

File tree

8 files changed

+36
-31
lines changed

8 files changed

+36
-31
lines changed

.circleci/config.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ jobs:
7070

7171
# Run the benchmark
7272
- run: node_modules/.bin/ibazel-benchmark-runner //src:devserver src/hello-world/hello-world.component.ts --url=http://localhost:5432
73-
74-
# Run the protractor end-to-end test - it's not a Bazel target because
75-
# we didn't write a protractor rule yet.
76-
- run: xvfb-run -a yarn e2e
7773

7874
- store_artifacts:
7975
path: dist/bin/src/bundle.min.js

BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@ filegroup(
4343
"*.js",
4444
"*.json",
4545
"*.d.ts",
46-
]]),
46+
]] + [
47+
"node_modules/protractor/**",
48+
]),
4749
)

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ bundlers can be integrated with Bazel.
8989
$ ibazel run src:prodserver
9090
```
9191

92-
We also use Protractor to run end-to-end tests. We don't have a protractor rule
93-
yet, so we'll take the build results from Bazel and run the test outside of Bazel.
94-
95-
```bash
96-
$ yarn e2e
97-
```
98-
9992
## Coming soon
10093

10194
- Protractor bazel rule

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@
2626
"typescript": "2.9.1"
2727
},
2828
"scripts": {
29-
"postinstall": "concurrently \"webdriver-manager update $CHROMEDRIVER_VERSION_ARG\" \"ngc -p postinstall.tsconfig.json\"",
29+
"postinstall": "ngc -p postinstall.tsconfig.json",
3030
"serve": "ibazel run //src:devserver",
31-
"pree2e": "bazel build test/...",
32-
"e2e": "yarn e2e-prodserver && yarn e2e-devserver",
33-
"e2e-prodserver": "concurrently \"bazel run //src:prodserver\" \"while ! nc -z 127.0.0.1 5432; do sleep 1; done && protractor\" --kill-others --success first",
34-
"e2e-devserver": "concurrently \"bazel run //src:devserver\" \"while ! nc -z 127.0.0.1 5432; do sleep 1; done && protractor\" --kill-others --success first",
3531
"prebuildifier": "bazel build @com_github_bazelbuild_buildtools//buildifier",
3632
"buildifier": "note: working around https://github.com/alexeagle/angular-bazel-example/issues/60",
3733
"buildifier": "find . -type f \\( -name BUILD -or -name BUILD.bazel \\) ! -path \"./node_modules/*\" | xargs $(bazel info bazel-bin)/external/com_github_bazelbuild_buildtools/buildifier/*/buildifier",

protractor.conf.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/e2e/BUILD.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
2+
load("@angular//:index.bzl", "protractor_web_test_suite")
23

34
ts_library(
45
name = "e2e",
56
testonly = 1,
67
srcs = glob(["*.ts"]),
78
)
9+
10+
protractor_web_test_suite(
11+
name = "prodserver_test",
12+
data = ["@angular//packages/bazel/src/protractor/utils"],
13+
on_prepare = ":protractor.on-prepare.js",
14+
server = "//src:prodserver",
15+
deps = [":e2e"],
16+
)
17+
18+
protractor_web_test_suite(
19+
name = "devserver_test",
20+
data = ["@angular//packages/bazel/src/protractor/utils"],
21+
on_prepare = ":protractor.on-prepare.js",
22+
server = "//src:devserver",
23+
deps = [":e2e"],
24+
)

test/e2e/protractor.on-prepare.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const protractorUtils = require('@angular/bazel/protractor-utils');
2+
const protractor = require('protractor');
3+
4+
module.exports = function(config) {
5+
const portFlag = config.server.endsWith('prodserver') ? '-p' : '-port';
6+
return protractorUtils.runServer(config.workspace, config.server, portFlag, [])
7+
.then(serverSpec => {
8+
const serverUrl = `http://localhost:${serverSpec.port}`;
9+
protractor.browser.baseUrl = serverUrl;
10+
});
11+
};

tools/history-server/index.bzl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ See https://www.npmjs.com/package/history-server
33
"""
44
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
55

6-
def history_server(port = 5432, args = [], **kwargs):
7-
if not args:
8-
args = [native.package_name()]
9-
args.extend(["-p", str(port)])
6+
def history_server(templated_args = [], **kwargs):
7+
if not templated_args:
8+
templated_args = [native.package_name()]
109
nodejs_binary(
1110
node_modules = "@history-server_runtime_deps//:node_modules",
1211
entry_point = "history-server/modules/cli.js",
13-
args = args,
12+
templated_args = templated_args,
1413
**kwargs)

0 commit comments

Comments
 (0)