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
378 stars 154 forks source link

Running rake spec:javascript from terminal does not find specs #220

Open momolog opened 6 years ago

momolog commented 6 years ago

When we go to /specs on our local server, we get

1 spec, 0 failures

but when we run RAILS_ENV=test bundle exec rake spec:javascript, it looks like there are no specs:

Running `"/usr/local/bin/phantomjs"  "/Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/jasmine-rails-0.14.2/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "file:///Users/aljoscha/rails/jovoto/tmp/jasmine/runner.html?spec="`
Running: file:///Users/aljoscha/rails/jovoto/tmp/jasmine/runner.html?spec=
Starting...

Finished
-----------------
0 specs, 0 failures in 0.004s.

ConsoleReporter finished

The weirdest part is, that opening the above mentioned file:///Users/aljoscha/rails/jovoto/tmp/jasmine/runner.html?spec= in a browser does run the spec successfully.

What could be the reason for this / how can we debug this?

tjefferson08 commented 6 years ago

I've seen this a few times in apps for work. In my experience, it's because there is unsupported ES6/ES2015 JS code in the tests (I'd check the app code too though)

I'd do a quick hunt/grep for fat arrow functions => Or template strings! Or const/let.

Etc.

EDIT: not sure why phantomjs chokes on the modern JS but that explains why running it e.g. Chrome works fine.

searls commented 6 years ago

Yes, phantomjs is deprecated/archived at this point and will never get various modern ES features, so unless code is compiled down to ES5 or lower, it'll choke. Headless mode for Chrome (and hopefully other browsers) are the future.

hunterae commented 2 years ago

@tjefferson08 : this is exactly what was happening with me - es6 syntax issues. Thanks for the suggestion!