【发布时间】: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