dflynn15 / gulp-jasmine-phantom

Gulp plugin to run Jasmine tests with Phantom or mininodejasmine2.
27 stars 30 forks source link

process hang out when specHtml param is passed #54

Closed sargiss closed 8 years ago

sargiss commented 8 years ago

call your plugin in following way: gulp.task('test', function(){ return gulp.src('tests/elements.js') .pipe(jasmine({ integration: true, specHtml: 'tests/elements.html', includeStackTrace:true})); });

It comes till that state and stop working. Just blinking cursor.

sergey@ubuntu:~/Projects/Timesheet$ gulp test [20:46:52] Using gulpfile ~/Projects/Timesheet/gulpfile.js [20:46:52] Starting 'test'... [20:46:52] Running Jasmine with PhantomJS [20:46:52] gulp-jasmine-phantom: Global Phantom undefined, trying to execute from node_modules/phantomjs

dflynn15 commented 8 years ago

Have you tried installing Phantom globally to see if that fixes the issue?

sargiss commented 8 years ago

resorted to your advice and installed phantomjs also globally: sudo npm install phantomjs -g

This did not change anything. Moreover I again get the same warning about that global phantom undefined

dflynn15 commented 8 years ago

Ok. What version of the plugin are you running?

sargiss commented 8 years ago

if you mean gulp-jasmine-phantom, 2.0.1

dflynn15 commented 8 years ago

Just for confirmation you can run phantomjs -v in your console and it is included in your $PATH?

sargiss commented 8 years ago

phantomjs -v 2.1.1

PATH contains phantomjs location

dflynn15 commented 8 years ago

Sorry for getting back so late, I am having a hard time replicating this specifically. Would you mind pointing me to a repo or posting your spec? I have a Ubuntu VM setup that seems to run a simple example just fine. I realize that isn't helpful, but replicating this has been very difficult and any additional information would be great.

Also, Node version and NPM version would be super helpful as well :grimacing:

sargiss commented 8 years ago

Thanks for your attention to issue. I ve had a lot of job past days, so I need some time to repeate all my steps and provide you with required information.

ChALkeR commented 8 years ago

@sargiss I had an issue with hanging gulp-jasmine-phantom due to phantomjs not being able to load the file (it exited with an error status, and gulp-jasmine-phantom haven't noticed it).

I did not find the exact reason, but the path that I was running everything in was long, contained non-latin chars, and (perhaps) contained symlinks. Moving everything to a nicer path solved things for me.

@dflynn15 gulp-jasmine-phantom hanging on phantomjs errors looks like a bug to me, perhaps fixing it would make things more easy to debug.

Update: That wasn't a phantomjs error, that was an error thrown by jasmine-runner.js being unable to load the file, see below.

dflynn15 commented 8 years ago

I recently ran into an issue where I have it not exiting, however only on a separate project, not the example tasks provided in the repository. If you get the same hanging experience with the examples in the repository that would help to know.

Currently I am narrowing it down to the project specific tests and not the plugin. If you are able to share the specs that may help as well (obviously if it is client or sensitive job info don't share them).

ChALkeR commented 8 years ago

@dflynn15, Try this:

  function execPhantom(phantom, childArguments, onComplete) {
+   childArguments[2] += 'foo';
    execFile(phantom, childArguments, function(error, stdout, stderr) {
      var success = null;

You will see that jasmine-runner.js errors with Couldn't load the page error (as it did with my path), but gulp-jasmine-phantom hangs. That error should bubble up somehow.

dflynn15 commented 8 years ago

I think what's interesting is that taking that same list of childArguments and executing phantomjs directly the process never exits.

i.e.

phantomjs lib/jasmine-runner.js lib/specRunner.html '{"integration": true, "keepRunner": false} foo'

With the process never exiting I'm not sure what the plugin can do to safely exit. We could obviously test to see how long the process has run and attempt to exit, but if there is a long standing test we may cut it off. I'll look and see if there are any events that Phantom so that maybe internally we can intercept the error.

ChALkeR commented 8 years ago

@dflynn15 This actually looks like a bug in lib/jasmine-runner.js to me. Btw, I made a mistype, I meant [1], not [2]:

$ phantomjs ./node_modules/gulp-jasmine-phantom/lib/jasmine-runner.js ./node_modules/gulp-jasmine-phantom/lib/specRunner.htmlfoo '{"integration": true, "keepRunner": false}'
Couldn't load the page

^C
ChALkeR commented 8 years ago

@dflynn15 Perhaps it needs a phantom.exit(1) call after those messages?

dflynn15 commented 8 years ago

Yep. Adding that phantom.exit(1) will fix it. Putting in a bug update :+1:

dflynn15 commented 8 years ago

This PR should fix it, but if you have time to test it out to see if it fixes your issue before I merge it that would be awesome!

https://github.com/dflynn15/gulp-jasmine-phantom/pull/57