jonkemp/gulp-qunit — pull request #8 by jgoz (2014-03-18 23:40:14+00:00)
Title: Transform absolute file paths to file URI scheme

This is a fix for the issues reported in #3, #7 and maybe #4.

1. Phantomjs appears to have issues processing relative paths for referenced files (e.g., script/style refs) when its webpage is created via an absolute path. (I was unable to find a relevant issue on the phantomjs GH page.)
2. `gulp.src` produces absolute paths in some cases/environments, which will trigger (1) when using this plugin. I'm not really clear on when this occurs, but it happens on my Win8.1/x64 machine.

This fix will determine if a file path is absolute and, if so, will transform it to the file URI scheme (e.g., `file:///c:/path/to/test.html`), which phantomjs *can* handle. Relative file paths remain untouched.

I also included a test case demonstrating the behaviour.

---

For anyone else affected by this issue, there is a workaround that you can add to your gulpfile. Fixing it here in the repository would obviously be preferable, but the following works in my environment:

```js
var gulp = require("gulp");
var qunit = require("gulp-qunit");
var path = require("path"),
var util = require('util');
var Transform = require('stream').Transform;

util.inherits(FilePathToUrl, Transform);

function FilePathToUrl(options){
Transform.call(this, options);
}

FilePathToUrl.prototype._transform = function(file, encoding, done) {
file.path = 'file:///' + path.resolve(file.path).replace(/\\/g, '/');
this.push(file);
return done();
};

function toUrl() {
return new FilePathToUrl({ objectMode: true });
}

gulp.task("test", function() {
return gulp.src("./qunit/test-runner.html")
.pipe(toUrl())
.pipe(qunit());
});
```