运行mocha xxx.js后里面的document为undefined,怎么得打正确的document?
这个问题的描述:
http://stackoverflow.com/questions/10091025/defining-window-for-testing-in-mocha
运行mocha xxx.js后里面的document为undefined,怎么得打正确的document?
这个问题的描述:
http://stackoverflow.com/questions/10091025/defining-window-for-testing-in-mocha
13 回答12.8k 阅读
8 回答2.6k 阅读
2 回答5.1k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
5 回答845 阅读
3 回答2.6k 阅读✓ 已解决
3 回答2.1k 阅读
是在node下运行的,node中没有window变量。
可以试试在浏览器中运行mocha
运行上面命令,就会在xxx目录下生成index.html文件。
类似于
再讲要测试的文件引入到html文件中,应该就可以访问window变量了吧。
以上是我的猜测,没有实际尝试,谢谢