Permalink
Browse files

feat(bazel): protractor_web_test_suite for release (#24787)

PR Close #24787
  • Loading branch information...
gregmagolan authored and matsko committed Jul 6, 2018
1 parent 71e0df0 commit 161ff5c79d0d3bfe9a5c79a2a1412cd06109c276
Showing with 924 additions and 311 deletions.
  1. +3 −0 BUILD.bazel
  2. +8 −5 WORKSPACE
  3. +4 −0 integration/bazel/BUILD.bazel
  4. +12 −3 integration/bazel/WORKSPACE
  5. +4 −8 integration/bazel/package.json
  6. +0 −5 integration/bazel/protractor.conf.js
  7. +3 −5 integration/bazel/src/BUILD.bazel
  8. +28 −1 integration/bazel/test/e2e/BUILD.bazel
  9. +1 −1 integration/bazel/test/e2e/app.spec.ts
  10. +12 −0 integration/bazel/test/e2e/on-prepare.ts
  11. +5 −0 integration/bazel/test/e2e/tsconfig.json
  12. +26 −101 integration/bazel/yarn.lock
  13. +4 −1 packages/bazel/index.bzl
  14. +1 −0 packages/bazel/src/BUILD.bazel
  15. +11 −2 packages/bazel/src/protractor/BUILD.bazel
  16. +0 −14 packages/bazel/src/protractor/conf.js.tmpl
  17. +154 −0 packages/bazel/src/protractor/protractor.conf.js
  18. +0 −23 packages/bazel/src/protractor/protractor_runner.js
  19. +341 −0 packages/bazel/src/protractor/protractor_web_test.bzl
  20. +0 −107 packages/bazel/src/protractor/protractor_web_test_suite.bzl
  21. +16 −0 packages/bazel/src/protractor/utils/BUILD.bazel
  22. +94 −0 packages/bazel/src/protractor/utils/index.ts
  23. +6 −0 packages/bazel/src/protractor/utils/tsconfig.json
  24. +54 −0 packages/bazel/test/protractor-2/BUILD.bazel
  25. +12 −0 packages/bazel/test/protractor-2/app.ts
  26. +11 −0 packages/bazel/test/protractor-2/conf.js
  27. +9 −0 packages/bazel/test/protractor-2/index.html
  28. +22 −0 packages/bazel/test/protractor-2/on-prepare.js
  29. +28 −0 packages/bazel/test/protractor-2/test.spec.ts
  30. +5 −0 packages/bazel/test/protractor-2/tsconfig.json
  31. +11 −2 packages/bazel/test/protractor/BUILD.bazel
  32. +0 −29 packages/bazel/test/protractor/conf.js
  33. +30 −0 packages/bazel/test/protractor/conf.ts
  34. +5 −0 packages/bazel/test/protractor/tsconfig.json
  35. +4 −4 tools/http-server/http_server.bzl
@@ -35,6 +35,9 @@ node_modules_filegroup(
"@types",
"@webcomponents/custom-elements",
],
patterns = [
"node_modules/protractor/**",
],
)
filegroup(
@@ -13,15 +13,18 @@ http_archive(
http_archive(
name = "bazel_gazelle",
sha256 = "d03625db67e9fb0905bbd206fa97e32ae9da894fe234a493e7517fd25faec914",
url = "https://github.com/bazelbuild/bazel-gazelle/releases/download/0.10.1/bazel-gazelle-0.10.1.tar.gz",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/0.12.0/bazel-gazelle-0.12.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/0.12.0/bazel-gazelle-0.12.0.tar.gz",
],
sha256 = "ddedc7aaeb61f2654d7d7d4fd7940052ea992ccdb031b8f9797ed143ac7e8d43",
)
http_archive(
name = "io_bazel_rules_webtesting",
url = "https://github.com/bazelbuild/rules_webtesting/archive/v0.2.0.zip",
strip_prefix = "rules_webtesting-0.2.0",
sha256 = "cecc12f07e95740750a40d38e8b14b76fefa1551bef9332cb432d564d693723c",
url = "https://github.com/bazelbuild/rules_webtesting/archive/7ffe970bbf380891754487f66c3d680c087d67f2.zip",
strip_prefix = "rules_webtesting-7ffe970bbf380891754487f66c3d680c087d67f2",
sha256 = "4fb0dca8c9a90547891b7ef486592775a523330fc4555c88cd8f09270055c2ce",
)
http_archive(
@@ -1,5 +1,9 @@
package(default_visibility = ["//visibility:public"])
exports_files([
"protractor.conf.js",
])
filegroup(
name = "node_modules",
srcs = glob(
@@ -11,11 +11,20 @@ http_archive(
sha256 = "634206524d90dc03c52392fa3f19a16637d2bcf154910436fe1d669a0d9d7b9c",
)
http_archive(
name = "bazel_gazelle",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/0.12.0/bazel-gazelle-0.12.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/0.12.0/bazel-gazelle-0.12.0.tar.gz",
],
sha256 = "ddedc7aaeb61f2654d7d7d4fd7940052ea992ccdb031b8f9797ed143ac7e8d43",
)
http_archive(
name = "io_bazel_rules_webtesting",
url = "https://github.com/bazelbuild/rules_webtesting/archive/v0.2.0.zip",
strip_prefix = "rules_webtesting-0.2.0",
sha256 = "cecc12f07e95740750a40d38e8b14b76fefa1551bef9332cb432d564d693723c",
url = "https://github.com/bazelbuild/rules_webtesting/archive/8fd9ce0fd9254bde251da0bc373d6cd08e811434.zip",
strip_prefix = "rules_webtesting-8fd9ce0fd9254bde251da0bc373d6cd08e811434",
sha256 = "4baee95fcfadfbaf868707af8accfd1cb98c5d13f808908e0152468bfb47f0f7",
)
http_archive(
@@ -18,17 +18,13 @@
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
"@types/jasmine": "2.8.7",
"@types/source-map": "0.5.1",
"concurrently": "3.5.1",
"http-server": "0.11.1",
"protractor": "file:../../node_modules/protractor",
"tsutils": "file:../../node_modules/tsutils",
"typescript": "file:../../node_modules/typescript"
},
"scripts": {
"postinstall": "concurrently \"webdriver-manager update $CHROMEDRIVER_VERSION_ARG\" \"ngc -p angular.tsconfig.json\"",
"test": "bazel build //... --noshow_progress && yarn e2e",
"pree2e": "bazel build test/...",
"e2e": "yarn e2e-prodserver && yarn e2e-devserver",
"e2e-prodserver": "concurrently \"bazel run //src:prodserver\" \"while ! nc -z 127.0.0.1 5432; do sleep 1; done && protractor\" --kill-others --success first",
"e2e-devserver": "concurrently \"bazel run //src:devserver\" \"while ! nc -z 127.0.0.1 5432; do sleep 1; done && protractor\" --kill-others --success first"
"postinstall": "ngc -p angular.tsconfig.json",
"test": "bazel build ... --noshow_progress && bazel test ..."
}
}
}
@@ -1,9 +1,4 @@
exports.config = {
specs: ['bazel-bin/test/e2e/*.spec.js'],
capabilities: {browserName: 'chrome', chromeOptions: {args: ['--no-sandbox']}},
directConnect: true,
baseUrl: 'http://localhost:5432/',
framework: 'jasmine',
getPageTimeout: 60 * 1000,
allScriptsTimeout: 60 * 1000,
};
@@ -1,3 +1,5 @@
package(default_visibility = ["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
# Allow targets under sub-packages to reference the tsconfig.json file
@@ -46,15 +48,11 @@ genrule(
nodejs_binary(
name = "prodserver",
args = [
"./src",
"-p",
"5432",
],
data = [
"index.html",
":bundle",
":zone.js",
],
entry_point = "http-server/bin/http-server",
templated_args = ["src"],
)
@@ -1,7 +1,34 @@
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
load("@angular//:index.bzl", "protractor_web_test_suite")
ts_library(
name = "e2e",
testonly = 1,
srcs = glob(["*.ts"]),
srcs = ["app.spec.ts"],
)
ts_library(
name = "ts_on_prepare",
testonly = 1,
srcs = ["on-prepare.ts"],
tsconfig = ":tsconfig.json",
deps = ["@angular//src/protractor/utils"],
)
protractor_web_test_suite(
name = "devserver_test",
configuration = "//:protractor.conf.js",
data = ["@angular//src/protractor/utils"],
on_prepare = ":ts_on_prepare",
server = "//src:devserver",
deps = [":e2e"],
)
protractor_web_test_suite(
name = "prodserver_test",
configuration = "//:protractor.conf.js",
data = ["@angular//src/protractor/utils"],
on_prepare = ":ts_on_prepare",
server = "//src:prodserver",
deps = [":e2e"],
)
@@ -1,4 +1,4 @@
import {browser, by, element, ExpectedConditions} from 'protractor';
import {browser, by, element} from 'protractor';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000;
@@ -0,0 +1,12 @@
import { browser } from 'protractor';
import {OnPrepareConfig, runServer} from '@angular/bazel/protractor-utils';
export = function(config: OnPrepareConfig) {
const portFlag = config.server.endsWith('prodserver') ? '-p' : '-port';
return runServer(config.workspace, config.server, portFlag, [])
.then(serverSpec => {
const serverUrl = `http://localhost:${serverSpec.port}`;
console.log(`Server has been started, starting tests against ${serverUrl}`);
browser.baseUrl = serverUrl;
});
}
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"lib": ["es2015"]
}
}
Oops, something went wrong.

0 comments on commit 161ff5c

Please sign in to comment.