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 })
]
});
});
});
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With