angular - 如何从单元测试 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;
在我的单元测试中访问它,以便我可以为其分配一个模拟值。我怎样才能访问这个变量?
解决方案
推荐阅读
- node.js - 如何将使用 puppeteer 和 node.js 抓取的数据放入 xml wordpress 文件中
- angular - 如何使 Angular cli 允许我使用内容哈希作为其名称来加载网站图标
- scala - 如何知道 Scala 中 Map 值 Map("key->"value") 的类型?
- c - 在 C 中反转列表后打印单链表时出现问题
- node.js - nodejs路由刷新问题无法获取/
- reactjs - React Router + 页面动画 + 模块化
- javascript - 更改显示属性会使不透明度过渡无效
- python - Python:如何在没有索引的情况下访问列表中的字典元素?
- javascript - 如何从自定义创建的 SVG 创建一个简单的代码,该代码可以放置在其他网站上
- c# - c#如何检测Netflix是否正在运行