【问题标题】:Jasmine/PhantomJs spec runnerJasmine/PhantomJs 规范运行器
【发布时间】:2014-09-08 13:24:43
【问题描述】:

我无法使用 phantomJs 运行测试。

gulp 任务

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>

独立运行此文件会报告我在exportToCsvSpec 中的所有测试都通过了。但是,当我尝试运行我的 gulp 任务时,我得到以下信息:

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:

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

代码位于此处,如果您想使用它Linky CI 也位于此处,供感兴趣的人使用Other Linky

【问题讨论】:

    标签: unit-testing jasmine phantomjs gulp


    【解决方案1】:

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

    From the jasmine2-junit repo

    请注意,boot.js 文件是该文件的修改版本,具有相同的 默认 Jasmine 2.0 发行版提供的名称。这 唯一的修改是将 JUnitXmlReporter 添加为报告器。 目前,似乎不可能在仍在使用的同时添加记者 股票 boot.js。

    如您所见,here 只是在boot.js 文件中添加了几行代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多