简体   繁体   English

如何使用ReSharper自定义HTML工具进行JavaScript测试?

[英]How do I use the ReSharper custom HTML harness for JavaScript testing?

I've tried everything with this option trying to create a custom HTML harness for my QUnit tests. 我已尝试使用此选项尝试为我的QUnit测试创建自定义HTML线束。 I've consulted the limited documentation on their site but am getting nowhere, even though I've tried pretty much every combination of path syntax and option from the "Test harness location" dropdown. 我已经在他们的网站上查阅了有限的文档,但我无处可去,尽管我已经尝试了“测试工具位置”下拉列表中的路径语法和选项的几乎所有组合。

I have copied the default implementation to a test html file, and modified it very simply to have some custom titles and elements inside, but no matter where I put the file or how I define a path to it, every time I run the unit tests using ReSharper's test runner, either from inside a file containing tests, or running tests on the project, I just see the default ReSharper QUnit screen. 我已经将默认实现复制到测试html文件中,并且非常简单地将其修改为内部有一些自定义标题和元素,但无论我在何处放置文件或如何定义其路径,每次运行单元测试使用ReSharper的测试运行器,无论是从包含测试的文件内部还是在项目上运行测试,我只看到默认的ReSharper QUnit屏幕。

I've also tried to use this using PhantomJS and not the browser to no avail. 我也尝试使用PhantomJS而不是浏览器无效。

I should be able to use this option to customize an HTML page for my JS tests, using syntax identical to Chutzpah, correct? 我应该可以使用此选项为我的JS测试自定义HTML页面,使用与Chutzpah相同的语法,对吗? I am using Resharper 9.0.0.0. 我正在使用Resharper 9.0.0.0。

Here's the contents of the file I'm attempting to point ReSharper to: 这是我试图将ReSharper指向的文件的内容:

(update: here's the fixed file that works with Jasmine) (更新:这是与Jasmine一起使用的固定文件)

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>testing!!!</title>
    @@ReferencedCSSFiles@@
    @@TestFrameworkDependencies@@
    @@ReferencedJSFiles@@
    @@ReSharperIntegration@@
</head>

<body>
    Some Custom Content Here
</body>
</html>

I changed my test syntax to Jasmine, and it worked. 我将测试语法更改为Jasmine,并且它有效。 ReSharper doesn't appear to use this template when running QUnit tests. 运行QUnit测试时,ReSharper似乎不使用此模板。

Honestly, most VS integrated solutions (including Chutzpah) don't work very well. 老实说,大多数VS集成解决方案(包括Chutzpah)都不能很好地工作。

For some time, my solution to testing in Visual Studio, is to have a recent version of node.js (or io.js) installed, with a package.json and gulp tasks setup to run tests as a pre/post build event. 有一段时间,我在Visual Studio中进行测试的解决方案是安装最新版本的node.js(或io.js),并设置package.json和gulp任务以将测试作为前/后构建事件运行。 I tend to favor mocha for tests, but qunit should be possible as well. 我倾向于喜欢用mocha进行测试,但是qunit也应该是可能的。

I believe that the latest Node Tools for Visual Studio (NTVS) does include gulp task runner integration. 我相信最新的Visual Studio节点工具(NTVS)确实包含了gulp任务运行器集成。

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

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