Angular 如何从单元测试中访问'declare`d变量&;因果报应/茉莉花
我的代码中有类似的内容:Angular 如何从单元测试中访问'declare`d变量&;因果报应/茉莉花,angular,typescript,unit-testing,jasmine,Angular,Typescript,Unit Testing,Jasmine,我的代码中有类似的内容: import { Component, OnInit } from '@angular/core'; import { AlertController, App, Events, Platform } from "ionic-angular"; declare let PushNotification: any; @Component({ selector: 'push', template: `` }) expo
import {
Component,
OnInit
} from '@angular/core';
import {
AlertController,
App,
Events,
Platform
} from "ionic-angular";
declare
let PushNotification: any;
@Component({
selector: 'push',
template: ``
})
export class PushComponent implements OnInit {
nav: any;
_push: any;
我想访问这个
声明:any代码>在我的单元测试中,这样我就可以给它分配一个模拟值。如何访问此变量?如何在代码中使用此变量?@Andrei在代码中此变量使用外部库代码初始化和加载。所以我们只需要调用PushNotification.get_Notification(),这样看起来它是全局的。提供模拟为window.PushNotification=…