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

Failed: Can't resolve all parameters for NavParams: (?) #195

Closed
SoldierCorp opened this issue Dec 14, 2016 · 2 comments
Closed

Failed: Can't resolve all parameters for NavParams: (?) #195

SoldierCorp opened this issue Dec 14, 2016 · 2 comments

Comments

@SoldierCorp
Copy link

Hi!

I'm manually compiling the test bed for my component because I had an error using TestUtils but now I have this error:

Failed: Can't resolve all parameters for NavParams: (?)

I'm calling a function from the construction to get the NavParams I was doing this from the ionViewDidLoad() but since I upgraded to rc3 I had to move all my declarations from ionViewDidLoad() to the constructor.

Do you have any idea?

@lathonez
Copy link
Owner

please see #191

@AshuSingh07
Copy link

import NavParammock from ionic-mocks and in provider getinstance of NavParamMock as below code sample:

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {

NavParamsMock

} from "ionic-mocks";
import {GlobalproviderProvider} from "../../providers/globalprovider/globalprovider";
import { ErrorlogPage } from './errorlog';

import {
IonicModule,
NavController,
NavParams
} from "ionic-angular";

describe('ErrorlogPage (with beforeEach)', () => {
let component: ErrorlogPage;
let fixture: ComponentFixture;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ErrorlogPage ],
imports: [ IonicModule.forRoot(ErrorlogPage)

  ],
  providers:[ 
  {provide: NavParams, useFactory: () => NavParamsMock.instance()},
	NavController,
	GlobalproviderProvider
	
	
   ]
})
.compileComponents();

}));

beforeEach(() => {
fixture = TestBed.createComponent(ErrorlogPage);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create error component', () => {
expect(component).toBeDefined();
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants