Skip to content

Commit b3d8af7

Browse files
committed
build: run e2e tests with bazel
* Builds the e2e app with Bazel * Serves the e2e app with Bazel * Runs the e2e tests with Bazel protractor rules
1 parent d22f48c commit b3d8af7

File tree

5 files changed

+75
-168
lines changed

5 files changed

+75
-168
lines changed

src/e2e-app/BUILD.bazel

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package(default_visibility=["//visibility:public"])
2+
3+
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver")
4+
load("//tools:defaults.bzl", "ng_module")
5+
6+
ng_module(
7+
name = "e2e-app",
8+
srcs = glob(["**/*.ts"]),
9+
assets = glob(["**/*.html", "**/*.css"], exclude = ["index.html"]),
10+
deps = [
11+
"@angular//packages/core",
12+
"@angular//packages/forms",
13+
"@angular//packages/platform-browser",
14+
"@angular//packages/platform-browser/animations",
15+
"@angular//packages/router",
16+
"//src/cdk/drag-drop",
17+
"//src/cdk/overlay",
18+
"//src/cdk/scrolling",
19+
# TODO(devversion): be more explicit by using "@angular/material" with individual entry points.
20+
"//src/lib:material",
21+
"//src/material-examples:examples",
22+
"//src/cdk-experimental/dialog",
23+
"//src/cdk-experimental/scrolling",
24+
],
25+
)
26+
27+
ts_devserver(
28+
name = "devserver",
29+
port = 4200,
30+
# Name of the AMD module that should be required on page load.
31+
entry_module = "angular_material/src/e2e-app/main",
32+
# Serving path of the bundle that serves all files specified in "deps" and "scripts".
33+
serving_path = "/bundle.js",
34+
# Root paths can be used simplify the loading of files from external Bazel repositories
35+
# (such as the Bazel managed deps repository called "matdeps")
36+
additional_root_paths = [
37+
"angular_material/",
38+
"matdeps/node_modules",
39+
],
40+
# Files which should be provided by Bazel when running the devserver. These are not
41+
# automatically served, but can be loaded manually through HTTP requests.
42+
static_files = [
43+
"@matdeps//zone.js",
44+
"@matdeps//core-js",
45+
"@matdeps//hammerjs",
46+
"//src/lib/prebuilt-themes:indigo-pink",
47+
":index.html",
48+
],
49+
# Scripts which will be included in the serving_path bundle after "require.js" has been
50+
# loaded.
51+
scripts = [
52+
":devserver-configure.js",
53+
"@matdeps//node_modules/tslib:tslib.js",
54+
],
55+
# Dependencies that produce JavaScript output will be automatically included in the
56+
# serving_path bundle
57+
deps = [":e2e-app"],
58+
)

src/e2e-app/devserver-configure.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// We need to configure AMD modules which are not named because otherwise "require.js" is not
2+
// able to resolve AMD imports to such modules.
3+
require.config({
4+
paths: {
5+
'moment': 'moment/min/moment.min'
6+
}
7+
});
8+
9+
// Workaround until https://github.com/angular/material2/issues/13883 has been addressed.
10+
var module = {id: ''};

src/e2e-app/index.html

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,20 @@
99
<link rel="icon" type="image/x-icon" href="favicon.ico">
1010
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
1111
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
12-
<link href="dist/packages/material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
12+
<link href="src/lib/prebuilt-themes/indigo-pink.css" rel="stylesheet">
1313

1414
<!-- FontAwesome for mat-icon demo. -->
1515
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
1616
</head>
1717
<body>
1818
<e2e-app>Loading...</e2e-app>
1919

20-
<script src="node_modules/core-js/client/core.js"></script>
21-
<script src="node_modules/systemjs/dist/system.src.js"></script>
22-
<script src="node_modules/zone.js/dist/zone.js"></script>
23-
<script src="node_modules/hammerjs/hammer.min.js"></script>
20+
<!-- Static scripts which are not imported through AMD nor part of the ConcatJS bundle. -->
21+
<script src="core-js/client/core.min.js"></script>
22+
<script src="zone.js/dist/zone.min.js"></script>
23+
<script src="hammerjs/hammer.min.js"></script>
2424

25-
<script>
26-
System.import('system-config.js').then(function () {
27-
System.import('main');
28-
}).catch(console.error.bind(console));
29-
</script>
25+
<!-- ConcatJS bundle from the Bazel TypeScript devserver. -->
26+
<script src="bundle.js"></script>
3027
</body>
3128
</html>

src/e2e-app/system-config.ts

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

src/e2e-app/tsconfig-build.json

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

0 commit comments

Comments
 (0)