3

I have recently started to use grunt for JS project.

I have got a plugin called 'grunt-contrib-jasmine' that I'm using for Jasmine testing. I works great but I'm not able to run tests by specrunner in browser. Can I achieve this by using this plugin or do I need to install something else.

Also when a plugin is not required anymore, is it best to just comment it out or is there any command to uninstall, eg: npm uninstall grunt-contrib-jasmine --save-dev

4

2 回答 2

4

为了澄清起见,您可以在浏览器中手动加载_SpecRunner.html文件,但 grunt 插件只会在 PhantomJS 中运行测试。

您可以keepRunner:true在 gruntfile 中指定选项以_SpecRunner.html在测试运行后保留该文件。

然后,您可以在项目的根目录中启动一个静态 Web 服务器(grunt-contrib-connectnode-static都可以正常工作),并且您应该能够_SpecRunner.html在浏览器中手动打开它并在那里运行您的测试。

编辑:我最终尝试了Testem,它可以在 PhantomJS真实浏览器中启动您的测试。现在还为时过早,但我想我会搁置 grunt-contrib-jasmine 以支持Testemgrunt-contrib-testem

于 2013-12-10T17:29:26.660 回答
1

grunt-contrib-jasmine仅适用于无头浏览器(phantomjs),所以我担心您将无法在浏览器中运行它。您将需要手动设置。

要卸载插件,请使用您提到的命令:

它将从 package.json 中删除条目,它也会卸载包。

于 2013-10-24T13:14:53.087 回答