Jasmine/PhantomJs spec runner

泄露秘密 提交于 2020-01-14 08:50:30

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/24807505/jasmine-phantomjs-spec-runner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!