在@ViewChild变量中使用spyOn时出错

mengmeng

我有一个使用的组件

@ViewChild(NgbDropdown) public dropdown: NgbDropdown;

this.dropdown.isOpen();

在我的规格文件中,我需要将isOpen()结果模拟为true,但似乎无法对其进行监视。

收到此错误:

 Error: <spyOn> : could not find an object to spy upon for isOpen()
        Usage: spyOn(<object>, <methodName>)

提前致谢!

mengmeng

这与短绒有关

这是应该如何嘲笑

component.dropdown  = jasmine.createSpyObj(['isOpen']);

(component.dropdown as SpyObj<NgbDropdown>).isOpen.and.returnValue(true);

谢谢!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Jquery.val()函数中使用变量时出错

在 Azure Synapse 中使用 SQL 声明变量时出错

在Get-ADComputer筛选器中使用变量时出错

在 Python Selenium 的 xpath 中使用变量时出错

在Python calendar.monthrange中使用变量时出错

在宏变量(循环)SAS中使用PUT时出错

在正则表达式中使用变量时出错

在宏中使用“#”时出错

我想在主程序的函数中使用变量集,但是在声明变量时出错

通过[错误:不是数字变量]分组后在R中使用Levene测试时出错

在SQL Server 2008中使用表变量执行动态SQL查询时出错

在模板文件的表达式中使用未初始化的变量时出错

在test.js文件中使用智能合约变量时出错

在 Julia 中使用 Gurobi 添加具有重复索引的变量时出错

在R中使用rpart Package,为决策树模型选择所有变量时出错

在Matlab中使用parfor时出错//无法对parfor中的变量进行分类

尝试在R中使用整洁的点尝试输入任意数量的分组变量和汇总变量时出错

在 summarise_at() 中使用 n() 时出错

在VBA中使用数组时出错

在VB中使用isNumeric()时出错

在类中使用“枚举”时出错

在find命令中使用exec时出错

尝试在 ${ForEachIn} 中使用 File 时出错?

在模型中使用Nokogiri时出错

在 opencv 中使用 findContours 时出错

在 react native 中使用 geolib 时出错

在 postgresql 查询中使用“on conflict”时出错

在查询中使用“ ORDER BY count”时出错

尝试在 useMemo() 中使用 ref 时出错