Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Can't find variable jsApiReporter #47

Open
jackocnr opened this issue Jun 27, 2013 · 17 comments
Open

Can't find variable jsApiReporter #47

jackocnr opened this issue Jun 27, 2013 · 17 comments

Comments

@jackocnr
Copy link

I have installed the jasmine-rails gem, and installed phantomJS with homebrew (I'm running OSX 10.8.4) and my jasmine.yml was working fine with the plain jasmine gem. Now when I run

bundle exec rake spec:javascript

I get the following error:

$ phantomjs "/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/jasmine-rails-0.4.5/lib/tasks/runner.js" "file:///Users/user/workspace/bacon/spec/tmp/runner.html?spec=BFApp.Views.ActivityFeedTab"
Running: file:///Users/user/workspace/bacon/spec/tmp/runner.html?spec=BFApp.Views.ActivityFeedTab
ERROR: ReferenceError: Can't find variable: jsApiReporter
TRACE:
-> phantomjs://webpage.evaluate(): 3
rake aborted!
Error executing command: phantomjs "/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/jasmine-rails-0.4.5/lib/tasks/runner.js" "file:///Users/user/workspace/bacon/spec/tmp/runner.html?spec=BFApp.Views.ActivityFeedTab"
/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/jasmine-rails-0.4.5/lib/tasks/jasmine-rails_tasks.rake:5:in run_cmd' /Users/user/.rvm/gems/ruby-1.9.3-p327/gems/jasmine-rails-0.4.5/lib/tasks/jasmine-rails_tasks.rake:28:inblock (2 levels) in <top (required)>'
/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/task.rb:246:in call' /Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/task.rb:246:inblock in execute'
/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/task.rb:241:in each' /Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/task.rb:241:inexecute'
/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/task.rb:184:in block in invoke_with_call_chain' /Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/task.rb:177:ininvoke_with_call_chain'
/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/task.rb:170:in invoke' /Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/application.rb:143:ininvoke_task'
/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/application.rb:101:in block (2 levels) in top_level' /Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/application.rb:101:ineach'
/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/application.rb:101:in block in top_level' /Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/application.rb:110:inrun_with_threads'
/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/application.rb:95:in top_level' /Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/application.rb:73:inblock in run'
/Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/application.rb:160:in standard_exception_handling' /Users/user/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.0.4/lib/rake/application.rb:70:inrun'
/Users/user/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in eval' /Users/user/.rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in

'

@searls
Copy link
Member

searls commented Jun 29, 2013

That's no good! I can't tell a ton from the stack trace. Could you share a minimal project that replicates the issue?

@hung-phan
Copy link

I also run into this problem when developing my project. When running `RAILS_ENV=test bundle exec rake spec:javascript' I run into

RAILS_ENV=test bundle exec rake spec:javascript
Running `"/usr/bin/phantomjs" "/home/colorvisa/.rvm/gems/ruby-2.1.1/gems/jasmine-rails-0.9.1/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/home/colorvisa/workarea/working on/private-profile/tmp/jasmine/runner.html?spec="`
Running: /home/colorvisa/workarea/working on/private-profile/tmp/jasmine/runner.html?spec=
ERROR: ReferenceError: Can't find variable: jsApiReporter
TRACE:
 -> phantomjs://webpage.evaluate(): 4
rake aborted!
Error executing command: "/usr/bin/phantomjs" "/home/colorvisa/.rvm/gems/ruby-2.1.1/gems/jasmine-rails-0.9.1/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/home/colorvisa/workarea/working on/private-profile/tmp/jasmine/runner.html?spec="
/home/colorvisa/.rvm/gems/ruby-2.1.1/gems/jasmine-rails-0.9.1/lib/jasmine_rails/runner.rb:71:in `run_cmd'
/home/colorvisa/.rvm/gems/ruby-2.1.1/gems/jasmine-rails-0.9.1/lib/jasmine_rails/runner.rb:21:in `block in run'
/home/colorvisa/.rvm/gems/ruby-2.1.1/gems/jasmine-rails-0.9.1/lib/jasmine_rails/runner.rb:48:in `override_rails_config'
/home/colorvisa/.rvm/gems/ruby-2.1.1/gems/jasmine-rails-0.9.1/lib/jasmine_rails/runner.rb:9:in `run'
/home/colorvisa/.rvm/gems/ruby-2.1.1/gems/jasmine-rails-0.9.1/lib/tasks/jasmine-rails_tasks.rake:8:in `block (2 levels) in <top (required)>'
/home/colorvisa/.rvm/gems/ruby-2.1.1@global/bin/ruby_executable_hooks:15:in `eval'
/home/colorvisa/.rvm/gems/ruby-2.1.1@global/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => spec:javascript
(See full trace by running task with --trace)

However, when running in normal browser environment I do not get these errors localhost:3000/specs.

@alexcwatt
Copy link

I am experiencing the same problem — tests are fine in the browser, but when running the specs from the console, I get this error:

ERROR: ReferenceError: Can't find variable: jQuery
TRACE:
 -> https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js: 5

I stripped down the runner.html file to the following, and still get an error when running it with "/home/acwatt/.phantomjs/1.9.7/x86_64-linux/bin/phantomjs" "/home/acwatt/.rvm/gems/ruby-2.1.0/gems/jasmine-rails-0.10.5/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/home/acwatt/myproject/tmp/jasmine/runner.html?spec="

<!DOCTYPE html>
<html>
  <head>
    <meta content="text/html;charset=UTF-8" http-equiv="Content-Type"/>
    <title>Jasmine Specs</title>

    <link href="./assets/jasmine.css" media="screen" rel="stylesheet" />
<link href="./assets/jasmine-specs.css" media="screen" rel="stylesheet" />

    <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.min.js"></script>

    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
  </head>
</html>

Any ideas? Thanks, and happy new year!

@gfrivolt
Copy link

gfrivolt commented Jan 5, 2015

I'm having the same missing jsApiReporter variable issue. The specs pass but at the end the strange error shows up:

Running `"/usr/local/bin/phantomjs" "/home/runner/environet-ui/vendor/bundle/ruby/2.2.0/gems/jasmine-rails-0.10.5/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/home/runner/environet-ui/tmp/jasmine/runner.html?spec="`
Running: /home/runner/environet-ui/tmp/jasmine/runner.html?spec=
Starting...

Finished
-----------------
101 specs, 2 skipped or pending, 0 failures in 0.125s.

ConsoleReporter finished
ERROR: ReferenceError: Can't find variable: jsApiReporter
TRACE:
 -> phantomjs://webpage.evaluate(): 4
ERROR: ReferenceError: Can't find variable: jsApiReporter
TRACE:
 -> phantomjs://webpage.evaluate(): 4
......
...   Lot of  times
.......
ERROR: ReferenceError: Can't find variable: jsApiReporter
TRACE:
 -> phantomjs://webpage.evaluate(): 4
rake aborted!
Error executing command: "/usr/local/bin/phantomjs" "/home/runner/environet-ui/vendor/bundle/ruby/2.2.0/gems/jasmine-rails-0.10.5/lib/jasmine_rails/../assets/javascripts/jasmine-runner.js" "/home/runner/environet-ui/tmp/jasmine/runner.html?spec="
/home/runner/environet-ui/vendor/bundle/ruby/2.2.0/gems/jasmine-rails-0.10.5/lib/jasmine_rails/runner.rb:71:in `run_cmd'
/home/runner/environet-ui/vendor/bundle/ruby/2.2.0/gems/jasmine-rails-0.10.5/lib/jasmine_rails/runner.rb:21:in `block in run'
/home/runner/environet-ui/vendor/bundle/ruby/2.2.0/gems/jasmine-rails-0.10.5/lib/jasmine_rails/runner.rb:48:in `override_rails_config'
/home/runner/environet-ui/vendor/bundle/ruby/2.2.0/gems/jasmine-rails-0.10.5/lib/jasmine_rails/runner.rb:9:in `run'
/home/runner/environet-ui/vendor/bundle/ruby/2.2.0/gems/jasmine-rails-0.10.5/lib/tasks/jasmine-rails_tasks.rake:8:in `block (2 levels) in <top (required)>'
Tasks: TOP => spec:javascript
(See full trace by running task with --trace)

How is it possible that a global jasmine reference like jsApiReporter is missing?

@AntiFish03
Copy link

@fifigyuri, I had this issue using jasmine 2+, when adding blanket.js. the issue is that jasmine has changed and jasmine is not really global anymore. If you look at this diff getaroom/jasmine-rails@searls:master...master

It might assist you in either finding or resolving the issue. I apologize that I can't be more help at the moment.

** Disclaimer **
Also, I can't guarantee that my fork will work for you... I have made a lot of one off changes to support requirejs and blanket.

@gfrivolt
Copy link

gfrivolt commented Jan 6, 2015

Thank you @AntiFish03, I tried to go through it, there's certainly lot of things to learn from the code you gave.

@AntiFish03
Copy link

@fifigyuri I wish I could give you more but all I remember is that I ran into this issue and was able to fix it, so the problem has a solution.

@gfrivolt
Copy link

gfrivolt commented Jan 6, 2015

actually the problem showed up to be with phantomjs, we use now 1.9.7, version 1.9.8 has bugs, and the fixes are only on phantomjs master, no release before 2.0 is supposed to happen.

jamesottaway added a commit to ennova/jasmine-rails that referenced this issue Jun 30, 2015
jamesottaway added a commit to ennova/jasmine-rails that referenced this issue Jun 30, 2015
jamesottaway added a commit to ennova/jasmine-rails that referenced this issue Jun 30, 2015
@toddmazierski
Copy link

We were able to work around our Can't find variable: jsApiReporter errors by following @fifigyuri and @jamesottaway's lead, and adding an explicit PhantomJS dependency to our Rails project:

# Gemfile
gem 'phantomjs', '< 1.9.8', '>= 1.9'

Which, in turn, installed:

# Gemfile.lock
phantomjs (1.9.7.1)

Hope that's useful!

@hung-phan
Copy link

👍

@searls
Copy link
Member

searls commented Aug 10, 2015

So I'm a bit in the dark as to what's happening here. Is this an error that only affects people running PhantomJS 2.x and Require.js?

@cherimarie
Copy link

@searls I'm running phantomjs 1.9.8.0 and jasmine-rails 0.11.0, no require.js, and seeing it. Tried directly requiring phantomjs as @toddmazierski suggested, but that didn't fix it.

@AntiFish03
Copy link

@cherimarie or @toddmazierski, Are you using Jasmine 1.x or 2.x? I ask because Jasmine changed the boot file for 2.0+

https://github.com/jasmine/jasmine/blob/master/lib/jasmine-core/boot.js

And @searls I am just trying to help here... Least I can do since you gave me a great starting point to work from for what I needed.

@toddmazierski
Copy link

@AntiFish03, here's more from our Gemfile.lock:

    jasmine-core (2.3.4)
    jasmine-rails (0.10.8)
      jasmine-core (>= 1.3, < 3.0)
      phantomjs (>= 1.9)
      railties (>= 3.2.0)
      sprockets-rails

Hope this is useful!

@AntiFish03
Copy link

ok so Jasmine 2.3.4 (latest release) When I get home from work I will try a clean project. I think it has to do with the Jasmine Boot (https://github.com/searls/jasmine-rails/blob/v0.10.8/lib/assets/javascripts/jasmine-boot.js) given that it is drastically different from what Jasmine-Core recommends (https://github.com/jasmine/jasmine/blob/master/lib/jasmine-core/boot.js)

@cherimarie
Copy link

@AntiFish03

 jasmine-core (2.3.4)
 jasmine-jquery-rails (2.0.3)
 jasmine-rails (0.11.0)
      jasmine-core (>= 1.3, < 3.0)
      phantomjs (>= 1.9)
      railties (>= 3.2.0)
      sprockets-rails

@AntiFish03
Copy link

@cherimarie @toddmazierski, I can't replicate this with a new project can you give me an example of a spec and JS that is causing this? It looks like the ConsoleReporter is running given

Finished
-----------------
101 specs, 2 skipped or pending, 0 failures in 0.125s.

ConsoleReporter finished
ERROR: ReferenceError: Can't find variable: jsApiReporter

So I wonder if some of your JS is still executing after the test suites finish...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants