Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'mock' does not exist on type 'IAngularStatic'

I want to use the mock to make a new class,but i don't konw why this mock does not exist on type 'IAngularStatic'.following is my code.

import {} from 'jasmine';
import * as angular from 'angular';
import {StrategyTables} from "./strategyTables.component";
import {StrategyTablesService} from "./strategyTables.service";
import {Router} from "@angular/router";
import {Location } from '@angular/common';
import {inject,async,TestBed} from '@angular/core/testing';
describe('strategyTables.component',() => {

  class MockstrategyService extends StrategyTablesService{
    getContactById(id:number){
      return{
        "name": "lee"
      };
    }

  }
  beforeEach(() => {
    angular.mock.module(($provide) => {
      TestBed.configureTestingModule({
        providers: [
          $provide.value(StrategyTablesService, { useClass:MockstrategyService })
      ]
    });
    });
  });
like image 437
W.Wei Avatar asked May 09 '17 01:05

W.Wei


1 Answers

You probably forgot to install the typings for angular mock (@types/angular-mocks) which is in another project than the angularjs one (@types/angular).

npm install --save-dev @types/angular-mocks
like image 88
ylerjen Avatar answered Oct 01 '22 01:10

ylerjen