我正在使用qunit(http://qunitjs.com)与Karma测试运行器(http://karma-runner.github.io/0.8/index.html)一起玩.我成功创建并运行了简单的测试(100%JavaScript),但现在我正在尝试使用HTML fixture来测试与DOM节点交互的代码.我可以通过这种方式在"文件"中声明它们来加载这些灯具:
{pattern: 'fixtures/myfixture.html', watched: true, served: true, included: false}
Run Code Online (Sandbox Code Playgroud)
它得到了karma的服务器,但我不明白我怎么能访问它的DOM :(
假设我的fixture是一个包含以下标记的简单html文件:
<div id="container">hello world</div>
Run Code Online (Sandbox Code Playgroud)
如何编写可以访问该节点(div)的测试?据我所知,"文档"与"静态"文件夹下的"context.html"文件有关...那么我的夹具的HTML在哪里?