jasmine/gulp-jasmine-browser

Path for spec files on Windows, when run in browser

Closed this issue · 2 comments

Hello

On Windows, when used the below code for example

gulp.task('jasmine', function() {

var filesForTest = [ 'src/**/*.js', 'src/**/*_spec.js']
     return gulp.src(filesForTest)
         .pipe(jasmineBrowser.specRunner())
         .pipe(jasmineBrowser.server({port: 8888}));
});

if the spec files are in a relative folder like "src/tests/spec/.", the browser is trying to load this files like "tests\spec*_spec.js" which is fails, it should be "/" instead of "".

Please advice and thank you.

rdy commented

This might be the way that gulp is giving the files to the spec runner, have you tried gulp.src(filesForTest, {base: '.'}). I'm not certain if that will change your result, however.

Unfortunately, this is probably the way that gulp is passing windows paths around, the browser is expecting them to be passed to the browser which is unix style.

You could probably add gulp-slash to make sure the paths get converted for windows. I suppose we could pipe that in from of all paths to make sure windows paths get converted.

var gulpSlash = require('gulp-slash');
gulp.task('jasmine', function() {

var filesForTest = [ 'src/**/*.js', 'src/**/*_spec.js']
     return gulp.src(filesForTest)
         .pipe(gulpSlash())
         .pipe(jasmineBrowser.specRunner())
         .pipe(jasmineBrowser.server({port: 8888}));
});

I don't have a windows machine handy to try this out so you'll need to let me know if this works.

Thank you for your reply.
The thing is when running jasmine headlessly all is working great.
Using gulp-slash did not fix the problem, but using .src(filesForTest, {base: '.'}) did fix it. Also, the watch option also needs {base: '.'} or you might get duplicated specs in browser...
Thank you for your help.