Skip to content

Commit 33f160c

Browse files
devversionjelbourn
authored andcommitted
build: do not apply zone.js legacy browser patches in unit tests
Updates our infrastructure to not apply the zone.js legacy browser patches. We don't run Bazel tests in legacy browsers, and using the evergreen patches would match with the default CLI project setup. This ensures that we can better reproduce issues that would also surface in CLI projects. Before this change, tests could behave differently due to ZoneJS legacy patches. e.g. ZoneJS patches `Object.defineProperty` in a way that makes properties _always_ configurable, while the actual ECMAScript default is `configurable: false`. This meant that we couldn't catch: #19440. in our unit tests. We should fix this by not applying these legacy ZoneJS patches, and rather match with the default setup in CLI projects. Whenever we run legacy browser tests with Bazel, we would now need to load the legacy patches (as done with the CLI). We need to explore possible solutions for this, but that is not a critical task right now (given that we don't test legacy browsers with Bazel).
1 parent 15fae34 commit 33f160c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/defaults.bzl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,16 @@ def ng_web_test_suite(deps = [], static_css = [], bootstrap = [], tags = [], **k
252252
"@io_bazel_rules_webtesting//browsers:firefox-local",
253253
],
254254
bootstrap = [
255-
"@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
255+
# This matches the ZoneJS bundles used in default CLI projects. See:
256+
# https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/application/files/src/polyfills.ts.template#L58
257+
# https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/application/files/src/test.ts.template#L3
258+
# Note `zone.js/dist/zone.js` is aliased in the CLI to point to the evergreen
259+
# output that does not include legacy patches. See: https://github.com/angular/angular/issues/35157.
260+
# TODO: Consider adding the legacy patches when testing Saucelabs/Browserstack with Bazel.
261+
# CLI loads the legacy patches conditionally for ES5 legacy browsers. See:
262+
# https://github.com/angular/angular-cli/blob/277bad3895cbce6de80aa10a05c349b10d9e09df/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts#L141
263+
"@npm//:node_modules/zone.js/dist/zone-evergreen.js",
264+
"@npm//:node_modules/zone.js/dist/zone-testing.js",
256265
"@npm//:node_modules/reflect-metadata/Reflect.js",
257266
] + bootstrap,
258267
tags = ["native"] + tags,

0 commit comments

Comments
 (0)