Title: FakeAsync's tick flushs nested timeouts · Issue #33799 · angular/angular · GitHub
Open Graph Title: FakeAsync's tick flushs nested timeouts · Issue #33799 · angular/angular
X Title: FakeAsync's tick flushs nested timeouts · Issue #33799 · angular/angular
Description: 🐞 bug report Affected Package The issue is caused by package @angular/core/testing Is this a regression? dunno Description tick call flushs even nested timeouts that have not been installed at the call moment 🔬 Minimal Reproduction funct...
Open Graph Description: 🐞 bug report Affected Package The issue is caused by package @angular/core/testing Is this a regression? dunno Description tick call flushs even nested timeouts that have not been installed at the ...
X Description: 🐞 bug report Affected Package The issue is caused by package @angular/core/testing Is this a regression? dunno Description tick call flushs even nested timeouts that have not been installed at the ...
Opengraph URL: https://github.com/angular/angular/issues/33799
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"FakeAsync's tick flushs nested timeouts","articleBody":"# 🐞 bug report\r\n\r\n### Affected Package\r\nThe issue is caused by package @angular/core/testing\r\n\r\n\r\n### Is this a regression?\r\n\r\ndunno\r\n\r\n\r\n### Description\r\n\r\n`tick` call flushs even nested timeouts that have not been installed at the call moment\r\n\r\n\r\n## 🔬 Minimal Reproduction\r\n\r\n```ts\r\nfunction waitTwice(callback: () => any): void {\r\n window.setTimeout(() =>\r\n window.setTimeout(() => callback())\r\n );\r\n}\r\n\r\ndescribe('fakeAsync', () => {\r\n it('nested timers', fakeAsync(() => {\r\n const callback = jasmine.createSpy('callback');\r\n\r\n waitTwice(callback);\r\n\r\n expect(callback).not.toHaveBeenCalled();\r\n\r\n tick();\r\n\r\n expect(callback).not.toHaveBeenCalled();\r\n }));\r\n});\r\n```\r\n\r\nrepo with this test\r\n\r\n- `git clone git@github.com:artaommahe/fakeasync-nested-timeout.git`\r\n- `yarn install`\r\n- `yarn test`\r\n\r\n[test file](https://github.com/artaommahe/fakeasync-nested-timeout/blob/master/src/app/fakeasync.spec.ts)\r\n\r\n## 🔥 Exception or Error\r\n```\r\nChrome 78.0.3904 (Windows 10.0.0) fakeAsync nested timers FAILED\r\n Error: Expected spy callback not to have been called.\r\n```\r\n\r\n\r\n## 🌍 Your Environment\r\n\r\n**Angular Version:**\r\n\u003cpre>\u003ccode>\r\n\r\nAngular CLI: 8.3.18\r\nNode: 10.16.1\r\nOS: win32 x64\r\nAngular: 8.2.13\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... language-service, platform-browser, platform-browser-dynamic\r\n... router\r\n\r\nPackage Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect 0.803.18\r\n@angular-devkit/build-angular 0.803.18\r\n@angular-devkit/build-optimizer 0.803.18\r\n@angular-devkit/build-webpack 0.803.18\r\n@angular-devkit/core 8.3.18\r\n@angular-devkit/schematics 8.3.18\r\n@angular/cli 8.3.18\r\n@ngtools/webpack 8.3.18\r\n@schematics/angular 8.3.18\r\n@schematics/update 0.803.18\r\nrxjs 6.4.0\r\ntypescript 3.5.3\r\nwebpack 4.39.2\r\n\r\n\u003c/code>\u003c/pre>\r\n\r\n**Anything else relevant?**\r\n\r\nSame test works well with jest's timer functions\r\n\r\n```ts\r\njest.useFakeTimers();\r\nconst callback = jest.fn();\r\nwaitTwice(callback);\r\n\r\njest.runOnlyPendingTimers();\r\n\r\nexpect(callback).not.toHaveBeenCalled();\r\n\r\njest.runOnlyPendingTimers();\r\n\r\nexpect(callback).toHaveBeenCalled();\r\n```\r\n\r\nIt is a real world case (function with nested zero-timeouts) - we are forced to use this due to parent-child init hooks order for custom elements and for manual elements creation (creating components tree from string markup) when parent's ngAfterViewInit is called sooner than child's one.","author":{"url":"https://github.com/artaommahe","@type":"Person","name":"artaommahe"},"datePublished":"2019-11-13T16:22:47Z","url":"https://github.com/angular/angular/issues/33799"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fe535591-cf96-d508-fe31-3a06e900ff2b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A6C:96DDF:14E9970:1A7D0AE:6B012911 |
| html-safe-nonce | 6f553e4bcaa7fb5ad085b693cca25d73cc69a3186cf7faf8a04d186ca0abbb76 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTZDOjk2RERGOjE0RTk5NzA6MUE3RDBBRTo2QjAxMjkxMSIsInZpc2l0b3JfaWQiOiI1NzgyOTE3ODkzODMwMjg5NjgxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4edd12389d10ddb4e42a92bf8ce160e2a2ce6dd6dd2fd2d468a68ae7d9e053a0 |
| hovercard-subject-tag | issue:522329044 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/33799/issue_layout |
| twitter:image | https://opengraph.githubassets.com/363e6ce79aaa2b9203c898605b5aa53d23c52ed7d25b1c6800683d57535b5e5c/angular/angular/issues/33799 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/363e6ce79aaa2b9203c898605b5aa53d23c52ed7d25b1c6800683d57535b5e5c/angular/angular/issues/33799 |
| og:image:alt | 🐞 bug report Affected Package The issue is caused by package @angular/core/testing Is this a regression? dunno Description tick call flushs even nested timeouts that have not been installed at the ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | artaommahe |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width