René's URL Explorer Experiment


Title: Unit test within async using fixture.detectChanges() fails · Issue #89 · ionic-team/ionic-unit-testing-example · GitHub

Open Graph Title: Unit test within async using fixture.detectChanges() fails · Issue #89 · ionic-team/ionic-unit-testing-example

X Title: Unit test within async using fixture.detectChanges() fails · Issue #89 · ionic-team/ionic-unit-testing-example

Description: Hello, This is the issue description: Using the method from ComponentFixture .detectChanges() is failing when you use it within an async() unit test. How to reproduce: Clone this repo: git clone https://github.com/ionic-team/ionic-unit-t...

Open Graph Description: Hello, This is the issue description: Using the method from ComponentFixture .detectChanges() is failing when you use it within an async() unit test. How to reproduce: Clone this repo: git clone ht...

X Description: Hello, This is the issue description: Using the method from ComponentFixture .detectChanges() is failing when you use it within an async() unit test. How to reproduce: Clone this repo: git clone ht...

Opengraph URL: https://github.com/ionic-team/ionic-unit-testing-example/issues/89

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unit test within async using fixture.detectChanges() fails","articleBody":"Hello,\r\n\r\n**This is the issue description:**\r\nUsing the method from `ComponentFixture` .`detectChanges()` is failing when you use it within an `async()` unit test.\r\n\r\n**How to reproduce:**\r\n\r\n1. Clone this repo: `git clone https://github.com/ionic-team/ionic-unit-testing-example.git`\r\n2. Install packages: `cd ionic-unit-testing-example \u0026\u0026 sudo npm install`\r\n3. Add the following unit test to the `src/app/app.component.spec.ts`:\r\n\r\n```typescript\r\n  it( 'example test async with fixture.detectChanges()', async(() =\u003e {\r\n    fixture.detectChanges();\r\n  }));\r\n```\r\n\r\n4. Run tests: `npm run test-ci`\r\n\r\n**After running the tests, it fails with the following error:**\r\n\r\n```\r\n..ERROR: 'Unhandled Promise rejection:', 'invalid link: Page1', '; Zone:', 'angular', '; Task:', 'Promise.then', '; Value:', 'invalid link: Page1', undefined\r\n\r\nERROR: 'Unhandled Promise rejection:', 'invalid link: Page1', '; Zone:', 'angular', '; Task:', 'Promise.then', '; Value:', 'invalid link: Page1', undefined\r\nChrome 65.0.3325 (Linux 0.0.0) MyApp Component example test async with fixture.detectChanges() FAILED\r\n        Failed: Uncaught (in promise): invalid link: Page1\r\n        Error: Uncaught (in promise): invalid link: Page1\r\n            at resolvePromise (webpack:///node_modules/zone.js/dist/zone.js:824:0 \u003c- test-config/karma-test-shim.js:117151:31)\r\n            at Object.reject (webpack:///node_modules/zone.js/dist/zone.js:746:0 \u003c- test-config/karma-test-shim.js:117073:17)\r\n            at NavControllerBase._fireError (webpack:///node_modules/ionic-angular/navigation/nav-controller-base.js:223:0 \u003c- test-config/karma-test-shim.js:51342:16)\r\n            at NavControllerBase._failed (webpack:///node_modules/ionic-angular/navigation/nav-controller-base.js:216:0 \u003c- test-config/karma-test-shim.js:51335:14)\r\n            at webpack:///node_modules/ionic-angular/navigation/nav-controller-base.js:263:44 \u003c- test-config/karma-test-shim.js:51382:59\r\n            at ZoneDelegate.invoke (webpack:///node_modules/zone.js/dist/zone.js:392:0 \u003c- test-config/karma-test-shim.js:116719:26)\r\n............\r\n```\r\n**Expected result** should be at least not to throw this error when using `fixture.detectChanges()`.\r\n\r\nThe full `src/app/app.component.spec.ts` file would be as the following:\r\n\r\n```typescript\r\nimport { async, TestBed, fakeAsync, ComponentFixture, tick } from '@angular/core/testing';\r\nimport { IonicModule, Platform, MenuController, Menu } from 'ionic-angular';\r\n\r\nimport { StatusBar } from '@ionic-native/status-bar';\r\nimport { SplashScreen } from '@ionic-native/splash-screen';\r\n\r\nimport { MyApp } from './app.component';\r\nimport {\r\n  PlatformMock,\r\n  StatusBarMock,\r\n  SplashScreenMock\r\n} from '../../test-config/mocks-ionic';\r\nimport { Page } from 'ionic-angular/navigation/nav-util';\r\nimport { By } from '@angular/platform-browser';\r\n\r\ndescribe('MyApp Component', () =\u003e {\r\n  let fixture;\r\n  let component;\r\n\r\n  beforeEach(async(() =\u003e {\r\n    TestBed.configureTestingModule({\r\n      declarations: [MyApp],\r\n      imports: [\r\n        IonicModule.forRoot(MyApp)\r\n      ],\r\n      providers: [\r\n        { provide: StatusBar, useClass: StatusBarMock },\r\n        { provide: SplashScreen, useClass: SplashScreenMock },\r\n        { provide: Platform, useClass: PlatformMock }\r\n      ]\r\n    });\r\n  }));\r\n\r\n  beforeEach(() =\u003e {\r\n    fixture = TestBed.createComponent(MyApp);\r\n    component = fixture.componentInstance;\r\n  });\r\n\r\n  it('should be created', () =\u003e {\r\n    expect(component instanceof MyApp).toBe(true);\r\n  });\r\n\r\n  it('should have two pages', () =\u003e {\r\n    expect(component.pages.length).toBe(2);\r\n  });\r\n\r\n  it( 'example test async with fixture.detectChanges()', async(() =\u003e {\r\n    fixture.detectChanges();\r\n  }));\r\n\r\n});\r\n```\r\nDoest anyone at least know why this could be happenning? I don't know if this could even be an Angular bug with lazy loading or whatever.\r\n\r\nThe only reference to `Page1` is inside `src/app/app.component.ts` in order to set up the page as the rootPage of the app:\r\n\r\n```typescript\r\nimport { Component, ViewChild } from '@angular/core';\r\nimport { SplashScreen } from '@ionic-native/splash-screen';\r\nimport { StatusBar } from '@ionic-native/status-bar';\r\nimport { Nav, Platform, Menu } from 'ionic-angular';\r\n\r\n\r\n@Component({\r\n  templateUrl: 'app.html'\r\n})\r\nexport class MyApp {\r\n  @ViewChild(Nav) nav: Nav;\r\n\r\n  rootPage: any = 'Page1';\r\n\r\n  pages: Array\u003c{ title: string, component: any }\u003e;\r\n\r\n\r\n  constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {\r\n    // used for an example of ngFor and navigation\r\n    this.pages = [\r\n      { title: 'Page One', component: 'Page1' },\r\n      { title: 'Page Two', component: 'Page2' }\r\n    ];\r\n\r\n  }\r\n\r\n  ionViewDidLoad() {\r\n    this.platform.ready().then(() =\u003e {\r\n      // Okay, so the platform is ready and our plugins are available.\r\n      // Here you can do any higher level native things you might need.\r\n      this.statusBar.styleDefault();\r\n      this.splashScreen.hide();\r\n    });\r\n  }\r\n\r\n  openPage(page) {\r\n    // Reset the content nav to have just this page\r\n    // we wouldn't want the back button to show in this scenario\r\n    this.nav.setRoot(page.component);\r\n  }\r\n\r\n}\r\n\r\n```\r\n\r\nThank you in advance.\r\n\r\nRegards,\r\n\r\nDavid.","author":{"url":"https://github.com/Dellos7","@type":"Person","name":"Dellos7"},"datePublished":"2018-04-24T10:26:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/89/ionic-unit-testing-example/issues/89"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d71943f1-8d18-a5ae-d091-c08ddd4d3b4d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCB3E:26C2C1:1B4A30:2789EB:6A635422
html-safe-nonce730b3627a656025ca682cf4ebdcf9ea3bbf45566bd3b47bff719ae50f2f9fcfb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjNFOjI2QzJDMToxQjRBMzA6Mjc4OUVCOjZBNjM1NDIyIiwidmlzaXRvcl9pZCI6IjM3NDQ1NjgyMTgwNTUwMzc5ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaca344e084d9b0774382d45a87360fe08aefc230cfe554b1c2bf699affcc31471b
hovercard-subject-tagissue:317164156
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/ionic-team/ionic-unit-testing-example/89/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a335215a474b83dab81cd44630a55d74d5206cb5374f9779b6f97e6e7e376ae7/ionic-team/ionic-unit-testing-example/issues/89
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a335215a474b83dab81cd44630a55d74d5206cb5374f9779b6f97e6e7e376ae7/ionic-team/ionic-unit-testing-example/issues/89
og:image:altHello, This is the issue description: Using the method from ComponentFixture .detectChanges() is failing when you use it within an async() unit test. How to reproduce: Clone this repo: git clone ht...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameDellos7
hostnamegithub.com
expected-hostnamegithub.com
None59e55daad7174ca59d63c6974d58276ccb5477442e550bebb3c035e1bef11c94
turbo-cache-controlno-preview
go-importgithub.com/ionic-team/ionic-unit-testing-example git https://github.com/ionic-team/ionic-unit-testing-example.git
octolytics-dimension-user_id3171503
octolytics-dimension-user_loginionic-team
octolytics-dimension-repository_id85606733
octolytics-dimension-repository_nwoionic-team/ionic-unit-testing-example
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id85606733
octolytics-dimension-repository_network_root_nwoionic-team/ionic-unit-testing-example
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
release990295d92a4cc7b63fbbd83a046217cd7d77d49c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/ionic-team/ionic-unit-testing-example/issues/89#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fionic-team%2Fionic-unit-testing-example%2Fissues%2F89
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fionic-team%2Fionic-unit-testing-example%2Fissues%2F89
Sign up https://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=ionic-team%2Fionic-unit-testing-example
Reloadhttps://github.com/ionic-team/ionic-unit-testing-example/issues/89
Reloadhttps://github.com/ionic-team/ionic-unit-testing-example/issues/89
Reloadhttps://github.com/ionic-team/ionic-unit-testing-example/issues/89
Please reload this pagehttps://github.com/ionic-team/ionic-unit-testing-example/issues/89
ionic-team https://github.com/ionic-team
ionic-unit-testing-examplehttps://github.com/ionic-team/ionic-unit-testing-example
Notifications https://github.com/login?return_to=%2Fionic-team%2Fionic-unit-testing-example
Fork 144 https://github.com/login?return_to=%2Fionic-team%2Fionic-unit-testing-example
Star 370 https://github.com/login?return_to=%2Fionic-team%2Fionic-unit-testing-example
Code https://github.com/ionic-team/ionic-unit-testing-example
Issues 21 https://github.com/ionic-team/ionic-unit-testing-example/issues
Pull requests 4 https://github.com/ionic-team/ionic-unit-testing-example/pulls
Actions https://github.com/ionic-team/ionic-unit-testing-example/actions
Projects https://github.com/ionic-team/ionic-unit-testing-example/projects
Security and quality 0 https://github.com/ionic-team/ionic-unit-testing-example/security
Insights https://github.com/ionic-team/ionic-unit-testing-example/pulse
Code https://github.com/ionic-team/ionic-unit-testing-example
Issues https://github.com/ionic-team/ionic-unit-testing-example/issues
Pull requests https://github.com/ionic-team/ionic-unit-testing-example/pulls
Actions https://github.com/ionic-team/ionic-unit-testing-example/actions
Projects https://github.com/ionic-team/ionic-unit-testing-example/projects
Security and quality https://github.com/ionic-team/ionic-unit-testing-example/security
Insights https://github.com/ionic-team/ionic-unit-testing-example/pulse
Unit test within async using fixture.detectChanges() failshttps://github.com/ionic-team/ionic-unit-testing-example/issues/89#top
https://github.com/Dellos7
Dellos7https://github.com/Dellos7
on Apr 24, 2018https://github.com/ionic-team/ionic-unit-testing-example/issues/89#issue-317164156
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.