angular-docs-cn/packages/zone.js/lib
JiaLiPassion 82d54fe8c3 feat(zone.js): add jest fakeTimers support (#39016)
Close #38851, support `jest` fakeTimers APIs' integration with `fakeAsync()`.
After enable this feature, calling `jest.useFakeTimers()` will make all test
run into `fakeAsync()` automatically.

```
beforeEach(() => {
    jest.useFakeTimers('modern');
  });
  afterEach(() => {
    jest.useRealTimers();
  });

  test('should run into fakeAsync() automatically', () => {
    const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec');
    expect(fakeAsyncZoneSpec).toBeTruthy();
  });
```

Also there are mappings between `jest` and `zone` APIs.

- `jest.runAllTicks()` will call `flushMicrotasks()`.
- `jest.runAllTimers()` will call `flush()`.
- `jest.advanceTimersByTime()` will call `tick()`
- `jest.runOnlyPendingTimers()` will call `flushOnlyPendingTimers()`
- `jest.advanceTimersToNextTimer()` will call `tickToNext()`
- `jest.clearAllTimers()` will call `removeAllTimers()`
- `jest.getTimerCount()` will call `getTimerCount()`

PR Close #39016
2020-10-05 13:23:17 -07:00
..
browser fix(zone.js): should invoke xhr send task when no response error occurs (#38836) 2020-09-18 11:19:37 -07:00
closure build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
common refactor(zone.js): rename BlacklistedStackFrames to InternalZoneJsStackFrames (#38978) 2020-09-28 16:23:41 -04:00
extra fix(zone.js): remove unused Promise overwritten setter logic (#36851) 2020-06-11 18:56:19 -07:00
jasmine feat(zone.js): patch jasmine.createSpyObj to make properties enumerable to be true (#34624) 2020-06-29 12:22:08 -07:00
jest feat(zone.js): add jest fakeTimers support (#39016) 2020-10-05 13:23:17 -07:00
mix build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
mocha build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
node fix(zone.js): patch nodejs EventEmtter.prototype.off (#37863) 2020-07-24 15:45:00 -07:00
rxjs fix(zone.js): zone patch rxjs should return null _unsubscribe correctly. (#37091) 2020-07-27 12:10:27 -07:00
testing feat(zone.js): add jest fakeTimers support (#39016) 2020-10-05 13:23:17 -07:00
zone-spec feat(zone.js): add jest fakeTimers support (#39016) 2020-10-05 13:23:17 -07:00
BUILD.bazel Revert "build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#37727)" (#39097) 2020-10-02 10:56:53 -07:00
zone.api.extensions.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
zone.configurations.api.ts feat(zone.js): move MutationObserver/FileReader to different module (#31657) 2020-07-24 15:12:28 -07:00
zone.ts fix(zone.js): disable wrap uncaught promise rejection should handle primitive value (#38476) 2020-09-24 11:32:44 -04:00