Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasmine/PhantomJs spec runner

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

like image 480
Mike Fielden Avatar asked Jul 17 '14 15:07

Mike Fielden


1 Answers

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.

like image 60
Mike Fielden Avatar answered Oct 06 '22 16:10

Mike Fielden