From 9b0a7e2d7d7e35091b70769e8a47d48ecefdd3e8 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 13 Dec 2022 20:20:12 +0000 Subject: [PATCH] build: introduce `zone_compatible_jasmine_node_test` rule (#48538) Introduces a variant of `jasmine_node_test` that works with async/await in combination with ZoneJS. This is needed for tests relying on async/await in combinatin with change detection. Browser tests are already benefting from ESbuild async-await downleveling. Node tests would ideally not need this, but until ZoneJS supports native async/await we need to also process source files to avoid native async/await syntax. PR Close #48538 --- tools/defaults.bzl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/defaults.bzl b/tools/defaults.bzl index 9aae565c135..33afd443b90 100644 --- a/tools/defaults.bzl +++ b/tools/defaults.bzl @@ -418,6 +418,26 @@ def npm_package_bin(args = [], **kwargs): **kwargs ) + # TODO(devversion): Jasmine Node tests are only bundled using `spec_bundle` + # because `async/await` syntax needs to be downleveled for ZoneJS. In the + # future this can be removed when ZoneJS can work with native async/await in NodeJS. +def zone_compatible_jasmine_node_test(name, external = [], deps = [], bootstrap = [], **kwargs): + spec_bundle( + name = "%s_bundle" % name, + # Specs from this attribute are filtered and will be executed. We + # add bootstrap here for discovery of the module mappings aspect. + deps = deps + bootstrap, + bootstrap = bootstrap, + external = external + ["domino", "typescript"], + platform = "node", + ) + + jasmine_node_test( + name = name, + deps = [":%s_bundle" % name], + **kwargs + ) + def jasmine_node_test(name, srcs = [], data = [], bootstrap = [], env = {}, **kwargs): # Very common dependencies for tests deps = kwargs.pop("deps", []) + [