Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUnit object is not present on this page #3

Closed
tborychowski opened this issue Feb 11, 2014 · 9 comments
Closed

QUnit object is not present on this page #3

tborychowski opened this issue Feb 11, 2014 · 9 comments

Comments

@tborychowski
Copy link

I'm trying to switch from grunt to gulp and have some problems with this plugin.

This is what I have (and the same works for grunt-contrib-qunit):

gulp.task('test', function () { 
    return gulp.src('tests/*.html').pipe(qunit()); 
});

but I'm getting this error in the console:

[gulp] Finished 'test' in 9.96 ms
The `QUnit` object is not present on this page.

{ [Error: Command failed: ] killed: false, code: 1, signal: null }

Is there anything specific like a setting or something required for this to work?

(I'm on windows7, and all the latest versions of phantomjs, nodejs & its modules)

@jonkemp
Copy link
Owner

jonkemp commented Feb 11, 2014

What version of the plugin do you have? Can you post your test file?

I need more to go on to help you. Thanks!

@tborychowski
Copy link
Author

Thanks for helping me!

Plugins version is: "gulp-qunit": "~0.1.3"
And the tests I'm running are here.
It's a standard qunit test (that currently works in the browser as well as with grunt)

@jonkemp
Copy link
Owner

jonkemp commented Feb 11, 2014

My guess is that it's a problem with the relative path to the qunit.js file in your test. I'm using absolute paths in all my testing so that may be why I don't have the problem.

So making your path absolute may solve the problem. I will try to fix it so that relative paths work though. Thanks!

@tborychowski
Copy link
Author

Thanks! You're right, changing paths of all js files to absolute urls solved this issue.
Cannot wait for the fix though :-)

Also: this seems almost impossibly fast! (9ms comparing to 340ms when using grunt and 90ms in a browser)!

@jonkemp
Copy link
Owner

jonkemp commented Feb 12, 2014

I cannot reproduce this using local copies of qunit.js on Mac or Windows so I'm not sure what's going on. I can't fix it if I can't reproduce it. I would suggest trying this change and see if that fixes your relative paths issue.

gulp.task('test', function () { 
    return gulp.src('./tests/*.html').pipe(qunit()); 
});

@tborychowski
Copy link
Author

Hi,
I've tried what you suggested and unfortunately it didn't help.
However, I've done some debugging and:

  • it seems that the problem is caused (as you discovered earlier) by the relative paths instead of urls.
  • phantomjs can create a webpage only from a url and not a local path like this: D:\\Projects\\index.html.

So the solution that worked for me was:

  • add a file:/// prefix to the file path to make it a local url
  • replace \\ with /

I've changed 2 lines in index.js to the below and now everything works:

var fpath = ~file.path.indexOf('http') ? file.path : 'file:///' + file.path.replace(/\\/g, '/'),
    childArgs = [ path.join(__dirname, 'runner.js'), fpath ];

I hope this helps and thanks for your time.

@jonkemp jonkemp closed this as completed Feb 12, 2014
@dzearing
Copy link

+1 to tborychowski's comment. Fixing those 2 lines resolved this issue for me as well (experiencing the same thing.

(on windows, and my gulp file basically is the same as the above, referencing ./tests/*.html )

@jonkemp
Copy link
Owner

jonkemp commented Feb 24, 2014

I'll reopen this to get more data, but it clearly works for some without this fix. I'm wondering if this is an edge case.

@jonkemp
Copy link
Owner

jonkemp commented Mar 25, 2014

Please get the latest version 0.3.1. It has the fix for this. Thanks.

@jonkemp jonkemp closed this as completed Mar 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants