Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 5f519de

Browse files
committed
feat(jasmine): Switch jasmine patch to use microtask and preserve zone.
Previous implementation used setTimeout which make tests too slow. It also did not propagate zones across a reset.
1 parent fd1dfcc commit 5f519de

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Diff for: lib/jasmine/jasmine.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
if (!Zone) {
55
throw new Error('zone.js does not seem to be installed');
66
}
7-
8-
const SET_TIMEOUT = '__zone_symbol__setTimeout';
9-
const _global = typeof window == 'undefined' ? global : window;
10-
11-
127
// When you have in async test (test with `done` argument) jasmine will
138
// execute the next test synchronously in the done handler. This makes sense
149
// for most tests, but now with zones. With zones running next test
@@ -17,10 +12,14 @@ const _global = typeof window == 'undefined' ? global : window;
1712
// it. We override the `clearStack` method which forces jasmine to always
1813
// drain the stack before next test gets executed.
1914
(<any>jasmine).QueueRunner = (function (SuperQueueRunner) {
15+
const originalZone = Zone.current;
2016
// Subclass the `QueueRunner` and override the `clearStack` method.
2117

2218
function alwaysClearStack(fn) {
23-
_global[SET_TIMEOUT](fn, 0);
19+
const zone: Zone = Zone.current.getZoneWith('JasmineClearStackZone')
20+
|| Zone.current.getZoneWith('ProxyZoneSpec')
21+
|| originalZone;
22+
zone.scheduleMicroTask('jasmineCleanStack', fn);
2423
}
2524

2625
function QueueRunner(options) {

0 commit comments

Comments
 (0)