testdouble / jasmine-rails

A Jasmine runner for rails projects that's got you covered in both the terminal and the browser
http://rubygems.org/gems/jasmine-rails
MIT License
377 stars 154 forks source link

"PhantomJS has crashed" problem when upgrade to PhantomJS 2.1.1 #191

Open terryyin opened 8 years ago

terryyin commented 8 years ago

Got problem like

$ bundle exec rake spec:javascript
Running `"/usr/local/bin/phantomjs" "" "/Users/terry/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/jasmine-rails-0.12.4/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "file:///Users/terry/git/less-site/tmp/jasmine/runner.html?spec="`
Running: file:///Users/terry/git/less-site/tmp/jasmine/runner.html?spec=
Starting...
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.

Downgrade PhantomJS to 1.9.8 solved the problem.

searls commented 8 years ago

Could you create an example project that demonstrates the problem? Perhaps consider pushing a fork of https://github.com/searls/jasmine-rails-exploratory-tests that reproduces the issue?

jywarren commented 8 years ago

I'm getting the same or similar error -- though I'm on ARM, not x86. How do I run the tests on the exploratory-tests repository? bundle exec rake spec:javascript gave:

The path /home/warren/sites/jasmine-rails does not exist.

jywarren commented 8 years ago

I can't make much of it, but here's my log when i do it with debug=true:

https://gist.github.com/jywarren/c83f582a2c2387cdbfc6925722398881

mtomov commented 8 years ago

Same problem on my machine (linux, phantomjs 2.1.1). I think CircleCi experiences same problem

https://gist.github.com/mtomov/b5469ad032bc09cdb833d11fb1751c02

wenga86 commented 8 years ago

+1 Same problem, having issues on Mac and Linux. Any updates on this?

Sorry should have read from the command line first.

zacblazic commented 8 years ago

@mtomov: Circle uses 1.9.8 by default which works.

This is a pretty serious issue though, I too have jasmine-rails breaking with phantomjs 2.1.1 (haven't tested other 2.x releases). Platforms: Mac & Linux (Debian).

Will be downgrading to 1.9.8 for now.

searls commented 8 years ago

@zacblazic you can control the version of phantomjs that's used by locking to a specific version of the phantomjs gem, right?

Can anyone on this thread reproduce the issue with an example project? I just spent 30 minutes locally trying to and I couldn't, using PhantomJS 2.1.1 installed via homebrew.

jgarber623 commented 8 years ago

+1'ing this issue.

On Friday, with PhantomJS 2.1.1 installed via Homebrew and jasmine-rails 0.14.1, my test suite ran without error. Come Monday morning, I start experiencing the PhantomJS crashes reported by @terryyin and others.

My step-by-step to get to a working test suite:

  1. brew uninstall phantomjs
  2. brew tap homebrew/versions
  3. brew install phantomjs198
  4. Reload console/open a new Terminal window/etc. etc.
  5. Update Gemfile: gem 'phantomjs', '~> 1.9' and gem 'jasmine-rails', '~> 0.14.1'
  6. bundle install
  7. Confirm the installed version of the PhantomJS and jasmine-rails gems.
  8. Run rake spec:javascript and :clap:.

The above will use a system-level PhantomJS. I didn't try these steps using a version of PhantomJS installed by the gem to ~/.phantomjs so YMMV.

searls commented 8 years ago

Hey @jgarber623 are you able to provide a failing example project? I can't even get to that point

jgarber623 commented 8 years ago

@searls The app and hardware I experienced the issue on are private/employer-managed, so I can't share that code directly. I can see about replicating the problem on other hardware, but that might not necessarily address how the problem (for me, anyway) started over the course of a weekend when my computer sat unused. 🤔

It's a very curious problem, for sure.

(And thanks for jasmine-rails, by the way! 😁 )

jgarber623 commented 8 years ago

@searls Did a bit more digging in on this one and found the actual problem in my code.

In a particular spec file, I had code similar to:

describe('some bit of functionality', function() {
  it('does a thing.', function() {
    //
  });
});

That empty assertion callback was causing PhantomJS 2.1.1 to crash. It did not crash PhantomJS 1.9.8. The takeaway here is that empty describe callback functions appear to be okay (for now), but empty it callback functions should be avoided.

describe('some bit of functionality', function() {
  // this is okay
});

describe('some bit of functionality', function() {
  it('does a thing.', function() {
    // you're in for bad times
  });
});

I'm not sure if this will solve anyone else's problems, but it was the root problem in my codebase.

(Hat tip to @ju-Skinner for his help debugging this one.)

searls commented 8 years ago

@jgarber623 what if the it contains statements other than expect assertions? It only fails when there are no statements in the function?

jgarber623 commented 8 years ago

@searls Ran a couple quick experiments:

describe('some piece of functionality', function() {
  it('crashes PhantomJS.', function() {});
});

describe('some piece of functionality', function() {
  it('crashes PhantomJS.', function() {
    //
  });
});

describe('some piece of functionality', function() {
  it('crashes PhantomJS.', function() {
    'use strict';
  });
});

describe('some piece of functionality', function() {
  it('crashes PhantomJS.', function() {
    var foo = 'bar';
  });
});

describe('some piece of functionality', function() {
  it('is listed as a skipped or pending spec and does not crash PhantomJS.');
});

The top four examples all crash PhantomJS. The last one does not.

mtomov commented 8 years ago

I don't have any empty / pending / etc tests in my test suite, but phantomjs still crashes as described.

caphun commented 8 years ago

I'm on PhantomJS 2.1.1 and jasmine-rails 0.14.1. I was getting the "PhantomJS has crashed" error too with this simple test case:

describe('test', function(){
  it('test', function() {
    expect(null).toEqual(null)
  })
})

However the issue turned out not to be related to the test case itself but some compatibility error in my javascript application code. To see if you have any errors open tmp/jasmine/runner.html file that is generated after every test run and inspect the web console. Once resolved my test runner ran successfully.

thekindofme commented 7 years ago

In my case the issue was resolved by simply adding the missing () to the end of a method call (it was coffeescript).

- expect( @meter.poll ).toBeFalsy
+ expect( @meter.poll ).toBeFalsy()
mtomov commented 7 years ago

I'm pretty sure that this #194 fixed the issue for me. CircleCI also passes with that. Thanks a lot!

terryyin commented 7 years ago

After reading lib/assets/javascripts/jasmine-runner.js, I found the problem might partially be fixed by #194, but it also needs the pull request https://github.com/searls/jasmine-rails/pull/212 for a couple of bugs.