Skip to content

Commit 4b3b149

Browse files
JeanMecheAndrewKushnir
authored andcommitted
refactor(benchpress): remove zone-based testing utilities
Transition to zoneless.
1 parent ec26d38 commit 4b3b149

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

packages/benchpress/test/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//tools:defaults.bzl", "angular_jasmine_test", "ts_project")
1+
load("//tools:defaults.bzl", "ts_project", "zoneless_jasmine_test")
22

33
ts_project(
44
name = "test_lib",
@@ -13,7 +13,7 @@ ts_project(
1313
],
1414
)
1515

16-
angular_jasmine_test(
16+
zoneless_jasmine_test(
1717
name = "test",
1818
data = [
1919
":test_lib",

packages/service-worker/worker/test/happy_spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,9 @@ import {envIsSupported} from '../testing/utils';
12141214

12151215
const debuggerLogSpy = spyOn(driver.debugger, 'log');
12161216

1217+
// To drain the microtask queue (and process all rejections)
1218+
await new Promise((r) => setTimeout(r));
1219+
12171220
scope.handleUnhandledRejection('Test rejection reason');
12181221

12191222
expect(debuggerLogSpy).toHaveBeenCalledWith(

packages/service-worker/worker/testing/scope.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,10 @@ export class SwTestHarnessImpl
285285
if (!this.eventHandlers.has('unhandledrejection')) {
286286
throw new Error('No unhandledrejection handler registered');
287287
}
288-
const promise = Promise.reject(reason);
289-
// We want to simulate an unhandled rejection, but we don't want the test runner (Node)
290-
// to actually see an unhandled rejection and fail the test. So we attach a dummy handler.
291-
promise.catch(() => {});
292288
const event = {
293289
reason,
294-
promise,
295-
} as unknown as PromiseRejectionEvent;
290+
promise: Promise.reject(reason),
291+
} as PromiseRejectionEvent;
296292
this.eventHandlers.get('unhandledrejection')!.call(this, event);
297293
}
298294

0 commit comments

Comments
 (0)