Skip to content

Commit f2a9259

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 f226264 commit f2a9259

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
@@ -248,7 +248,16 @@ def ng_web_test_suite(deps = [], static_css = [], bootstrap = [], tags = [], **k
248248
"@io_bazel_rules_webtesting//browsers:firefox-local",
249249
],
250250
bootstrap = [
251-
"@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
251+
# This matches the ZoneJS bundles used in default CLI projects. See:
252+
# https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/application/files/src/polyfills.ts.template#L58
253+
# https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/application/files/src/test.ts.template#L3
254+
# Note `zone.js/dist/zone.js` is aliased in the CLI to point to the evergreen
255+
# output that does not include legacy patches. See: https://github.com/angular/angular/issues/35157.
256+
# TODO: Consider adding the legacy patches when testing Saucelabs/Browserstack with Bazel.
257+
# CLI loads the legacy patches conditionally for ES5 legacy browsers. See:
258+
# https://github.com/angular/angular-cli/blob/277bad3895cbce6de80aa10a05c349b10d9e09df/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts#L141
259+
"@npm//:node_modules/zone.js/dist/zone-evergreen.js",
260+
"@npm//:node_modules/zone.js/dist/zone-testing.js",
252261
"@npm//:node_modules/reflect-metadata/Reflect.js",
253262
] + bootstrap,
254263
tags = ["native"] + tags,

0 commit comments

Comments
 (0)