@angular/core/testing has no exported member 'MockApplicationRef'
Asked Answered
S

2

7

I want to run my old angular2 unit-test with new RC4 version, but I have a problem.

What happened to MockApplicationRef ?

What I should use here instead ?

provide(ApplicationRef, { useClass: MockApplicationRef})
Seisin answered 24/7, 2016 at 15:0 Comment(0)
B
3

Sure this is a delayed answer for this ticket, but if you arrived here from Google like me, the answer is here

Basically MockApplicationRef is replaced by TestBed and importing a new provider should do the trick:

import { TestBed, async } from '@angular/core/testing';
import {APP_BASE_HREF}    from '@angular/common';
...
...
beforeEach(() => {
TestBed.configureTestingModule({
  imports: [
    ...
  ],
  declarations: [
    AppComponent,
    ...
  ],
  providers: [
    {provide: APP_BASE_HREF, useValue: '/'}
  ]
});

Hope this helps.

Beaner answered 7/3, 2017 at 12:2 Comment(1)
Also base-href implementation added, just in caseBeaner
R
1

For future onlookers. I renamed one of my classes, and it was not updated. So make sure that your Component/class is named correctly, and also check the correct import path.

Ridotto answered 7/10, 2017 at 1:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.