Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests fail because of usage of Loading-/ToastController #8539

Closed
ivarreukers opened this issue Oct 6, 2016 · 3 comments
Closed

Unit tests fail because of usage of Loading-/ToastController #8539

ivarreukers opened this issue Oct 6, 2016 · 3 comments

Comments

@ivarreukers
Copy link

Short description of the problem:

note: my tests are working fine without a LoadingController
Unit tests fail because, use of LoadingController. This is caused because the LoadingController cannot be provided it seems. This issue would also relate to ex. the NavParams. Just how would one mock them/use them in TestBed

What behavior are you expecting?

That the tests will execute.

Steps to reproduce:

  1. Clone marcoturi's https://github.com/marcoturi/ionic2-boilerplate
  2. Setup a component with a LoadingController in the constructor
  3. Try to create an instance with angular's TestBed.
TestBed.configureTestingModule({
    declarations: [EventsPage],
    schemas: [CUSTOM_ELEMENTS_SCHEMA],
    providers: [
      {provide: APICaller, useValue: mockAPICaller},
      {provide: NavController, useValue: mockNavController },
      {provide: LoadingController, useValue: ???????}, //it seems like everything I try to enter here fails.
    ],
    imports: [FormsModule]
  });

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

http://stackoverflow.com/questions/39897625/ionic2-rc0-testing-mocking-ionics-toast-loadingcontroller

Which Ionic Version? 1.x or 2.x
2.1.0

Plunker that shows an example of your issue

don't know how to configure Plunkr into running jasmine tests.

Run ionic info from terminal/cmd prompt: (paste output below)

$ ionic info

Your system information:

Cordova CLI: 6.3.1
Gulp version:  CLI version 1.2.2
Gulp local:
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS:
Node Version: v4.5.0

@ivarreukers
Copy link
Author

edit: NavParams is able to stay using default NavParams. When using useClass: LoadingController the compiler complains about App! being undefined

@jgw96 jgw96 added the v2 label Oct 7, 2016
@danbucholtz
Copy link
Contributor

If you're injecting LoadingController, you also need to inject anything that it depends on, or create Mocks.

I'm going to close this for now as this is more of a question than an issue.

Thanks,
Dan

@ivarreukers
Copy link
Author

So how would you mock the App it asks for? Ionic's mockIonicApp doesnt work

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants