茉莉花/ PhantomJs规格赛跑者 [英] Jasmine/PhantomJs spec runner

查看:113
本文介绍了茉莉花/ PhantomJs规格赛跑者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

gulp任务



pre class =lang-js prettyprint-override> var jasminePhantomJs = require('gulp-jasmine2-phantomjs');
gulp.task('test',function(){
return gulp.src('./ SpecRunner.html')
.pipe(jasminePhantomJs());
} );

SpecRunner.html

 < script src =lib / jquery.min.js>< / script> 
< script src =lib / lodash.min.js>< / script>

< script type =text / javascriptsrc =lib / jasmine-2.0.0 / jasmine.js>< / script>
< script type =text / javascriptsrc =lib / jasmine-2.0.0 / jasmine-html.js>< / script>
< script type =text / javascriptsrc =lib / jasmine-2.0.0 / boot.js>< / script>
< script type =text / javascriptsrc =lib / jasmine-2.0.0 / jasmine-jquery.js>< / script>

<! - 包括此处的源文件... - >
< script type =text / javascriptsrc =dist / exportToCsv.js>< / script>

<! - 包括这里的规格文件... - >
< script type =text / javascriptsrc =spec / exportToCsvSpec.js>< / script>

运行此文件standalone报告 exportToCsvSpec

 使用gulpfile〜/ gulpfile.js 
开始'测试'...
开始运行spec文件:/ExportToCsv/SpecRunner.html
PhantomJS路径:/ ExportToCsv / node_modules / gulp-jasmine2-phantomjs / node_modules / phantomjs / lib / phantom / bin / phantomjs
加载/ExportToCsv/SpecRunner.html
页面已超时;中止。

gulp-jasmine2-phantomjs:✖断言在SpecRunner.html中失败
'test'在31 s后出错
插件'gulp-jasmine2-phantomjs'
出错命令失败:

虽然我对这个确切的gulp插件并不熟悉,但我并不陌生于幻象。我似乎无法弄清楚它为什么会失败。



如果您想使用它,代码位于此处 Linky
CI对于那些感兴趣的人来说也位于其他Linky

解决方案

解决了这个问题。在gulp插件 gulp-jasmine2-phantomjs 中提到了 jasmine2-junit 的要求,但我做了什么没有更新的 boot.js 文件, jasmine2-junit 需要。



来自jasmine2-junit回购
$ b


请注意,boot.js文件是具有相同
名称的文件的修改版本,由默认的Jasmine 2.0分配。
唯一的修改是将JUnitXmlReporter添加为记者。
目前,在仍然使用
股票boot.js的情况下添加记者似乎是不可能的。


你可以在这里看到这个变化只是添加到 boot.js 文件。


I cannot get my test to run using phantomJs.

gulp task

var jasminePhantomJs = require('gulp-jasmine2-phantomjs');
gulp.task('test', function() {
    return gulp.src('./SpecRunner.html')
        .pipe(jasminePhantomJs());
});

SpecRunner.html

<script src="lib/jquery.min.js"></script>
<script src="lib/lodash.min.js"></script>

<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/boot.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-jquery.js"></script>

<!-- include source files here... -->
<script type="text/javascript" src="dist/exportToCsv.js"></script>

<!-- include spec files here... -->
<script type="text/javascript" src="spec/exportToCsvSpec.js"></script>

Running this file standalone reports all my tests in exportToCsvSpec to be passing. However, when I attempt to run my gulp task I get the following:

Using gulpfile ~/gulpfile.js
Starting 'test'...
Start running spec file:  /ExportToCsv/SpecRunner.html
PhantomJS path:  /ExportToCsv/node_modules/gulp-jasmine2-phantomjs/node_modules/phantomjs/lib/phantom/bin/phantomjs
Loading /ExportToCsv/SpecRunner.html
Page has timed out; aborting.

gulp-jasmine2-phantomjs: ✖ Assertions failed in SpecRunner.html
'test' errored after 31 s
Error in plugin 'gulp-jasmine2-phantomjs'
Command failed:

While I'm not familiar with this exact gulp plugin I am not new to phantom. I can't seem to figure out why it's failing.

The code is located here if you'd like to play with it Linky CI is located here for those interested as well Other Linky

解决方案

Fixed this problem. In the gulp plugin gulp-jasmine2-phantomjs in mentions a requirement of jasmine2-junit which I had but what I did not have was the updated boot.js file that jasmine2-junit requires.

From the jasmine2-junit repo

Note that the boot.js file is a modified version of the file with same name that is provided by the default Jasmine 2.0 distribution. The only modification is that the JUnitXmlReporter is added as reporter. Currently, it seems impossible to add a reporter while still using the stock boot.js.

As you can see here the change was only a couple lines added to the boot.js file.

这篇关于茉莉花/ PhantomJs规格赛跑者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆