简体   繁体   English

使用Mocha进行DOM测试

[英]DOM tests with Mocha

Is it possible to test if a window has been opened by a JS function with Mocha? 是否可以通过Mocha测试JS函数是否已打开窗口?

For example part of a test is to see whether a window to, say, Facebook, has been opened in order for a user to share the current app, so is it possible for Mocha to detect a window has been opened when I call window.open(url, target) ? 例如,测试的一部分是查看是否已打开例如Facebook的窗口,以便用户共享当前应用程序,因此,当我调用window.open(url, target)时,Mocha可以检测到窗口是否已打开window.open(url, target)

Sure. 当然。 window.open returns null if the call fails, so as long as you have access to the return value in Mocha you can test whether or not it was successful. 如果调用失败,则window.open返回null ,因此,只要您可以访问Mocha中的返回值,就可以测试调用是否成功。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM