René's URL Explorer Experiment


Title: `@angular-devkit/build-angular` breaks Jasmine's mock clock · Issue #11626 · angular/angular-cli · GitHub

Open Graph Title: `@angular-devkit/build-angular` breaks Jasmine's mock clock · Issue #11626 · angular/angular-cli

X Title: `@angular-devkit/build-angular` breaks Jasmine's mock clock · Issue #11626 · angular/angular-cli

Description: Bug Report or Feature Request (mark with an x) - [x] bug report -> please search issues before submitting - [ ] feature request Command (mark with an x) - [x] test Versions > node --version v8.11.3 > npm --version 5.6.0 > ng --version An...

Open Graph Description: Bug Report or Feature Request (mark with an x) - [x] bug report -> please search issues before submitting - [ ] feature request Command (mark with an x) - [x] test Versions > node --version v8.11.3...

X Description: Bug Report or Feature Request (mark with an x) - [x] bug report -> please search issues before submitting - [ ] feature request Command (mark with an x) - [x] test Versions > node --version v...

Opengraph URL: https://github.com/angular/angular-cli/issues/11626

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`@angular-devkit/build-angular` breaks Jasmine's mock clock","articleBody":"### Bug Report or Feature Request (mark with an `x`)\r\n```\r\n- [x] bug report -> please search issues before submitting\r\n- [ ] feature request\r\n```\r\n\r\n### Command (mark with an `x`)\r\n```\r\n- [x] test\r\n```\r\n\r\n### Versions\r\n```\r\n> node --version\r\nv8.11.3\r\n\r\n> npm --version\r\n5.6.0\r\n\r\n> ng --version\r\nAngular CLI: 6.1.0-rc.3\r\nNode: 8.11.3\r\nOS: win32 x64\r\nAngular: 6.0.9\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... http, language-service, platform-browser\r\n... platform-browser-dynamic, router\r\n\r\nPackage                           Version\r\n-----------------------------------------------------------\r\n@angular-devkit/architect         0.7.0-rc.3\r\n@angular-devkit/build-angular     0.7.0-rc.3\r\n@angular-devkit/build-optimizer   0.7.0-rc.3\r\n@angular-devkit/build-webpack     0.7.0-rc.3\r\n@angular-devkit/core              0.7.0-rc.3\r\n@angular-devkit/schematics        0.7.0-rc.3\r\n@angular/cli                      6.1.0-rc.3\r\n@ngtools/webpack                  6.1.0-rc.3\r\n@schematics/angular               0.7.0-rc.3\r\n@schematics/update                0.7.0-rc.3\r\nrxjs                              6.2.2\r\ntypescript                        2.7.2\r\nwebpack                           4.9.2\r\n```\r\nOS: Windows 10\r\n\r\n### Repro steps\r\n1. `npm install --global @angular/cli`.\r\n2. `ng new test-app && cd test-app`.\r\n3. `npm test` --> Passed ✔️\r\n4. Add a test in `src/app/app.component.spec.ts` that uses `jasmine.clock().install()`. E.g.:\r\n    ```ts\r\n    it('should pass', () => {\r\n      jasmine.clock().install();\r\n      expect(true).toBe(true);\r\n      jasmine.clock().uninstall();\r\n    });\r\n    ```\r\n5. `npm test` --> Fails ❌\r\n    > Error: Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?\r\n\r\n### The log given by the failure\r\n```\r\nChrome 67.0.3396 (Windows 10.0.0) AppComponent should pass FAILED\r\n        Error: Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?\r\n            at UserContext.eval (webpack:///./src/app/app.component.spec.ts?:31:25)\r\n            at ZoneDelegate.invoke (webpack:///./node_modules/zone.js/dist/zone.js?:387:26)\r\n            at ProxyZoneSpec.onInvoke (webpack:///./node_modules/zone.js/dist/zone-testing.js?:287:39)\r\n            at ZoneDelegate.invoke (webpack:///./node_modules/zone.js/dist/zone.js?:386:32)\r\n            at Zone.run (webpack:///./node_modules/zone.js/dist/zone.js?:137:43)\r\n            at runInTestZone (webpack:///./node_modules/zone.js/dist/zone-testing.js?:508:34)\r\nChrome 67.0.3396 (Windows 10.0.0) AppComponent should pass FAILED\r\n        Error: Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?\r\n            at UserContext.eval (webpack:///./src/app/app.component.spec.ts?:31:25)\r\n            at ZoneDelegate.invoke (webpack:///./node_modules/zone.js/dist/zone.js?:387:26)\r\n            at ProxyZoneSpec.onInvoke (webpack:///./node_modules/zone.js/dist/zone-testing.js?:287:39)\r\n            at ZoneDelegate.invoke (webpack:///./node_modules/zone.js/dist/zone.js?:386:32)\r\n            at Zone.run (webpack:///./node_modules/zone.js/dist/zone.js?:137:43)\r\n            at runInTestZone (webpack:///./node_modules/zone.js/dist/zone-testing.js?:508:34)\r\n            at UserContext.eval (webpack:///./node_modules/zone.js/dist/zone-testing.js?:523:20)\r\nChrome 67.0.3396 (Windows 10.0.0): Executed 4 of 4 (1 FAILED) (0 secs / 0.433 secs)\r\nChrome 67.0.3396 (Windows 10.0.0) AppComponent should pass FAILED\r\n        Error: Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?\r\n            at UserContext.eval (webpack:///./src/app/app.component.spec.ts?:31:25)\r\n            at ZoneDelegate.invoke (webpack:///./node_modules/zone.js/dist/zone.js?:387:26)\r\n            at ProxyZoneSpec.onInvoke (webpack:///./node_modules/zone.js/dist/zone-testing.js?:287:39)\r\n            at ZoneDelegate.invoke (webpack:///./node_modules/zone.js/dist/zone.js?:386:32)\r\n            at Zone.run (webpack:///./node_modules/zone.js/dist/zone.js?:137:43)\r\n            at runInTestZone (webpack:///./node_modules/zone.js/dist/zone-testing.js?:508:34)\r\nChrome 67.0.3396 (Windows 10.0.0): Executed 4 of 4 (1 FAILED) (0.462 secs / 0.433 secs)\r\n```\r\n\r\n### Desired functionality\r\nNo errors :grin:\r\n\r\n### Mention any other details that might be useful\r\nAFAICT, the problem is caused by incorrect order of code execution. More specifically:\r\n- Jasmine stores the global timing functions (such as `setTimeout`).\r\n- When calling `jasmine.clock().install()`, it overwrites the timing functions with mocks.\r\n- Before doign so, it checks whether the currently global timing functions are different than what it has stored in step 1. If so, it assumes the clock is already installed (i.e. the functions are overwritten) and throws.\r\n- Zone.js also overwrites the global timing functions to make them zone-aware.\r\n\r\nIn order for this to work, Zone.js must patch the global functions before Jasmine stores the \"original\" global functions (to later compare them and determine if the clock is already installed). For some reason, it seems that Jasmine is storing the global functions before Zone.js has patched them. Then, once we call `jasmine.clock().install()`, Jasmine compares the orignal, unpatched global functions with the current global functions (which have since been patched  by Zone.js) and finds that they are not the same (and throws).\r\n\r\nI have no idea why this is happening, but by trying out several versions I have found out this is broken in `@angular-devkit/build-angular` v0.6.8 (and all the way through v0.7.0-rc.3). The commit that broke it is 0b126f6d3 and more specifically [this change][1].\r\n\r\nReverting the `test` property back to also check `!chunks.some(({ name }) => name === 'polyfills')` fixes the issue.\r\n\r\n[1]: https://github.com/angular/angular-cli/commit/0b126f6d34ac5d94a5fb96d38f23b2b690afd56d#diff-8311f86ef0adf0533613f54692cbd2abR80","author":{"url":"https://github.com/gkalpak","@type":"Person","name":"gkalpak"},"datePublished":"2018-07-23T12:24:22Z","url":"https://github.com/angular/angular-cli/issues/11626"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:48cb6b77-8b73-5572-4abf-01c235a54132
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDDEA:21AC3F:BEB1B9:F4E5A8:6B00E874
html-safe-noncecc9d7579414d87625b0edc2a2b6fd7f54e98b81059e7af8d4a54abff28813f6a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREVBOjIxQUMzRjpCRUIxQjk6RjRFNUE4OjZCMDBFODc0IiwidmlzaXRvcl9pZCI6IjgwNDkwNTk5NjkxMTY0NjUyNjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac58821a4a737d788124e3f4ef28b09db7a1b74b8c0b37e6ec0128619d81443994
hovercard-subject-tagissue:343610848
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/11626/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7c10b9e31003b4bc82800ce20b455f8da22a47c2699c1ba840ba85b6f8aa3fe5/angular/angular-cli/issues/11626
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7c10b9e31003b4bc82800ce20b455f8da22a47c2699c1ba840ba85b6f8aa3fe5/angular/angular-cli/issues/11626
og:image:altBug Report or Feature Request (mark with an x) - [x] bug report -> please search issues before submitting - [ ] feature request Command (mark with an x) - [x] test Versions > node --version v8.11.3...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegkalpak
hostnamegithub.com
expected-hostnamegithub.com
None27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14
turbo-cache-controlno-preview
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release624179fb8b88d26ba5bba08894eb60a1c5a1d93d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/11626#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F11626
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F11626
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/11626
Reloadhttps://github.com/angular/angular-cli/issues/11626
Reloadhttps://github.com/angular/angular-cli/issues/11626
angularhttps://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Codehttps://github.com/angular/angular-cli
Issues198 (198)https://github.com/angular/angular-cli/issues
Pull requests23 (23)https://github.com/angular/angular-cli/pulls
Actionshttps://github.com/angular/angular-cli/actions
Security and quality8 (8)https://github.com/angular/angular-cli/security
Insightshttps://github.com/angular/angular-cli/insights
https://github.com/angular/angular-cli
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/11626
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/11626
#11627https://github.com/angular/angular-cli/pull/11627
@angular-devkit/build-angular breaks Jasmine's mock clockhttps://github.com/angular/angular-cli/issues/11626#top
#11627https://github.com/angular/angular-cli/pull/11627
area: @angular-devkit/build-angularhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular-devkit%2Fbuild-angular%22
https://github.com/gkalpak
gkalpakhttps://github.com/gkalpak
on Jul 23, 2018https://github.com/angular/angular-cli/issues/11626#issue-343610848
0b126f6https://github.com/angular/angular-cli/commit/0b126f6d34ac5d94a5fb96d38f23b2b690afd56d
this changehttps://github.com/angular/angular-cli/commit/0b126f6d34ac5d94a5fb96d38f23b2b690afd56d#diff-8311f86ef0adf0533613f54692cbd2abR80
Nexthttps://github.com/angular/angular-cli/issues/11626?timeline_page=1
https://github.com/gkalpak
gkalpakhttps://github.com/gkalpak
on Jul 23, 2018https://github.com/angular/angular-cli/issues/11626#issuecomment-407040328
https://github.com/filipesilva
filipesilvahttps://github.com/filipesilva
on Jul 23, 2018https://github.com/angular/angular-cli/issues/11626#issuecomment-407044960
#11164https://github.com/angular/angular-cli/issues/11164
filipesilvahttps://github.com/filipesilva
area: @angular-devkit/build-angularhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular-devkit%2Fbuild-angular%22
on Jul 23, 2018https://github.com/angular/angular-cli/issues/11626#event-1747611063
https://github.com/gkalpak
gkalpakhttps://github.com/gkalpak
on Jul 23, 2018https://github.com/angular/angular-cli/issues/11626#issuecomment-407049719
#11164https://github.com/angular/angular-cli/issues/11164
https://github.com/gkalpak
gkalpakhttps://github.com/gkalpak
on Jul 23, 2018https://github.com/angular/angular-cli/issues/11626#issuecomment-407059175
#10485https://github.com/angular/angular-cli/issues/10485
#10485 (comment)https://github.com/angular/angular-cli/issues/10485#issuecomment-386990790
gkalpakhttps://github.com/gkalpak
on Jul 23, 2018https://github.com/angular/angular-cli/issues/11626#event-1747744736
fix(@angular-devkit/build-angular): do not break with Jasmine's mock …https://github.com/gkalpak/angular-cli/commit/b3a68404c7ecc65a8a0ac7da0421d9c96234f252
https://docs.github.com/articles/closing-issues-via-commit-messages
b3a6840https://github.com/gkalpak/angular-cli/commit/b3a68404c7ecc65a8a0ac7da0421d9c96234f252
fix(@angular-devkit/build-angular): do not break with Jasmine's mock …https://github.com/gkalpak/angular-cli/commit/e6497894cca1777cf6c3d37c8fe4277fd6c89622
https://docs.github.com/articles/closing-issues-via-commit-messages
e649789https://github.com/gkalpak/angular-cli/commit/e6497894cca1777cf6c3d37c8fe4277fd6c89622
fix(@angular-devkit/build-angular): do not break with Jasmine's mock …https://github.com/gkalpak/angular-cli/commit/c41a45cc2a481792166f7df2f19f8b598c1e8ff7
https://docs.github.com/articles/closing-issues-via-commit-messages
c41a45chttps://github.com/gkalpak/angular-cli/commit/c41a45cc2a481792166f7df2f19f8b598c1e8ff7
filipesilvahttps://github.com/filipesilva
completedhttps://github.com/angular/angular-cli/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#11627https://github.com/angular/angular-cli/pull/11627
on Jul 23, 2018https://github.com/angular/angular-cli/issues/11626#event-1748054950
filipesilvahttps://github.com/filipesilva
on Jul 23, 2018https://github.com/angular/angular-cli/issues/11626#event-1748055400
fix(@angular-devkit/build-angular): do not break with Jasmine's mock …https://github.com/angular/angular-cli/commit/e17a2edcc7d190ffa1ca5cf68c4d11c6687fe7ee
https://docs.github.com/articles/closing-issues-via-commit-messages
e17a2edhttps://github.com/angular/angular-cli/commit/e17a2edcc7d190ffa1ca5cf68c4d11c6687fe7ee
filipesilvahttps://github.com/filipesilva
on Aug 16, 2018https://github.com/angular/angular-cli/issues/11626#event-1792473708
fix(@angular-devkit/build-angular): do not break with Jasmine's mock …https://github.com/angular/angular-cli/commit/d7e3b844dcefe4e0a31a39aec37b95bb41355550
https://docs.github.com/articles/closing-issues-via-commit-messages
d7e3b84https://github.com/angular/angular-cli/commit/d7e3b844dcefe4e0a31a39aec37b95bb41355550
matskohttps://github.com/matsko
on Aug 27, 2018https://github.com/angular/angular-cli/issues/11626#event-1811531909
build(docs-infra): downgrade @angular-devkit/build-angular to 0.6.7 (#…https://github.com/angular/angular/commit/b3c56f021f0e8ca020fdeb9766b46990c0cc1cde
#…https://github.com/angular/angular/pull/19795
b3c56f0https://github.com/angular/angular/commit/b3c56f021f0e8ca020fdeb9766b46990c0cc1cde
alxhubhttps://github.com/alxhub
on Oct 3, 2018https://github.com/angular/angular-cli/issues/11626#event-1882949014
build(docs-infra): downgrade @angular-devkit/build-angular to 0.6.7 (#…https://github.com/angular/angular/commit/a273491be08dc264538d9857920ca1a299af702b
#…https://github.com/angular/angular/pull/25997
a273491https://github.com/angular/angular/commit/a273491be08dc264538d9857920ca1a299af702b
https://github.com/whyboris
whyborishttps://github.com/whyboris
on Nov 16, 2018https://github.com/angular/angular-cli/issues/11626#issuecomment-439378377
https://github.com/angular/zone.js/issues/1063#issuecomment-377674202https://github.com/angular/zone.js/issues/1063#issuecomment-377674202
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 8, 2019https://github.com/angular/angular-cli/issues/11626#issuecomment-529248364
automatic conversation locking policyhttps://github.com/angular/angular/blob/67d80f/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 8, 2019https://github.com/angular/angular-cli/issues/11626#event-2617043006
mostafaibrhttps://github.com/mostafaibr
on May 29, 2026https://github.com/angular/angular-cli/issues/11626#event-26099538896
fix(@angular-devkit/build-angular): do not break with Jasmine's mock …https://github.com/mostafaibr/angular-cli/commit/0e890b8ccba33bf5d3bcb2829a67b68060eb8c69
https://docs.github.com/articles/closing-issues-via-commit-messages
0e890b8https://github.com/mostafaibr/angular-cli/commit/0e890b8ccba33bf5d3bcb2829a67b68060eb8c69
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular-cli/issues/11626
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/11626
area: @angular-devkit/build-angularhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22area%3A%20%40angular-devkit%2Fbuild-angular%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.