首页 > 解决方案 > 如何从单元测试 Angular 和 Karma/Jasmine 访问`declare`d 变量

问题描述

我的代码中有这样的内容:

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;

我想declare let PushNotification: any;在我的单元测试中访问它,以便我可以为其分配一个模拟值。我怎样才能访问这个变量?

标签: angulartypescriptunit-testingjasmine

解决方案


推荐阅读