angular-cn/packages/zone.js/lib
JiaLiPassion 4374931b0e fix(zone.js): zone.js patch jest should handle done correctly (#36022)
`zone.js` supports jest `test.each()` methods, but it
introduces a bug, which is the `done()` function will not be handled correctly.

```
it('should work with done', done => {
  // done will be undefined.
});
```

The reason is the logic of monkey patching `test` method is different from `jasmine` patch

// jasmine patch
```
return testBody.length === 0
   ? () => testProxyZone.run(testBody, null)
   : done => testProxyZone.run(testBody, null, [done]);
```

// jest patch
```
 return function(...args) {
   return testProxyZone.run(testBody, null, args);
 };
```

the purpose of this change is to handle the following cases.

```
test.each([1, 2])('test.each', (arg1, arg2) => {
  expect(arg1).toBe(1);
  expect(arg2).toBe(2);
});
```

so in jest, it is a little complex, because the `testBody`'s parameter may be bigger than 1, so the
logic in `jasmine`

```
return testBody.length === 0
   ? () => testProxyZone.run(testBody, null)
   : done => testProxyZone.run(testBody, null, [done]);
```
will not work for `test.each` in jest.

So in this PR, I created a dynamic `Function` to return the correct length of paramters (which is required by jest core), to handle
1. normal `test` with or without `done`.
2. each with parameters with or without done.

PR Close #36022
2020-04-07 15:22:16 -07:00
..
browser feat(zone.js): Monkey patch MessagePort.prototype onproperties (#34610) 2020-03-16 08:59:38 -07:00
closure fix(zone.js): __load_patch and __symbol__ should be in zone_extern for closure compiler (#31350) 2019-07-24 13:30:01 -07:00
common style(zone.js): fix lint errors after clang update (#36487) 2020-04-07 10:10:34 -07:00
extra fix(zone.js): don't fire unhandledrejection if Zone handled error (#31718) 2019-07-24 16:10:59 -07:00
jasmine feat: make jasmine patch as zone module (#34676) 2020-02-10 16:23:47 -08:00
jest fix(zone.js): zone.js patch jest should handle done correctly (#36022) 2020-04-07 15:22:16 -07:00
mix fix(zone.js): zone-mix should import correct browser module (#31628) 2019-07-24 14:33:07 -07:00
mocha feat: make mocha a zone module. (#34719) 2020-02-11 11:41:58 -08:00
node refactor: utilize type narrowing (#33075) 2019-10-10 15:18:44 -07:00
rxjs fix(zone.js): zone.js patches rxjs should check null for unsubscribe (#35990) 2020-03-16 09:01:17 -07:00
testing feat: add an tickOptions parameter with property processNewMacroTasksSynchronously. (#33838) 2020-02-20 15:14:59 -08:00
zone-spec fix(zone.js): `tickOptions`'s `processNewMacroTasksSynchronously` should default to true when flag omitted (#35814) 2020-03-06 17:33:57 -05:00
BUILD.bazel build: reference zone.js from source directly instead of npm. (#33046) 2019-11-06 00:48:34 +00:00
zone.api.extensions.ts fix(zone.js): Make `EventTarget` methods optional in `zone.js` extension API (#35954) 2020-03-16 09:00:44 -07:00
zone.configurations.api.ts fix(zone.js): UNPATCHED_EVENTS and PASSIVE_EVENTS should be string[] not boolean (#36258) 2020-04-01 13:20:00 -07:00
zone.ts fix(zone.js): don't rely on global node typings outside of node/ directory (#31783) 2019-07-30 12:59:40 -07:00