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

43 lines
1.2 KiB
JSON

{
"name": "zone.js",
"version": "0.11.2",
"description": "Zones for JavaScript",
"main": "./bundles/zone.umd.js",
"module": "./fesm2015/zone.js",
"es2015": "./fesm2015/zone.js",
"fesm2015": "./fesm2015/zone.js",
"typings": "./zone.d.ts",
"dependencies": {
"tslib": "^2.0.0"
},
"devDependencies": {
"@types/node": "^10.9.4",
"domino": "2.1.2",
"jest": "^26.4",
"mocha": "^3.1.2",
"mock-require": "3.0.3",
"promises-aplus-tests": "^2.1.2",
"typescript": "4.0.2"
},
"scripts": {
"electrontest": "cd test/extra && node electron.js",
"jest:test": "jest --config ./test/jest/jest.config.js ./test/jest/jest.spec.js",
"jest:nodetest": "jest --config ./test/jest/jest.node.config.js ./test/jest/jest.spec.js",
"promisetest": "tsc -p . && node ./test/promise/promise-test.js",
"promisefinallytest": "tsc -p . && mocha ./test/promise/promise.finally.spec.js"
},
"repository": {
"type": "git",
"url": "git://github.com/angular/angular.git",
"directory": "packages/zone.js"
},
"publishConfig": {
"registry": "https://wombat-dressing-room.appspot.com"
},
"author": "Brian Ford",
"license": "MIT",
"bugs": {
"url": "https://github.com/angular/angular/issues"
}
}