jejacks0n / teaspoon

Teaspoon: Javascript test runner for Rails. Use Selenium, BrowserStack, or PhantomJS.
1.43k stars 243 forks source link

CircleCI: ReferenceError: Can't find variable: Teaspoon #427

Closed hakunin closed 8 years ago

hakunin commented 8 years ago

Just installed Teaspoon and my example test works both as /teaspoon and in command line (without any warnings), but not on CircleCI, any ideas?

bundle exec teaspoon
Starting the Teaspoon server...
WEBrick 1.3.1
ruby 2.2.1 (2015-02-26) [x86_64-linux]
Rack::Handler::WEBrick is mounted on /.
WEBrick::HTTPServer#start: pid=12097 port=43627
Teaspoon running default suite at http://127.0.0.1:43627/teaspoon/default
accept: 127.0.0.1:52752
close: 127.0.0.1:52752
accept: 127.0.0.1:52763
Rack::Handler::WEBrick is invoked.
Started GET "/teaspoon/default?reporter=Console" for 127.0.0.1 at 2015-11-03 16:39:55 +0000
Processing by Teaspoon::SuiteController#show as HTML
  Parameters: {"reporter"=>"Console", "suite"=>"default"}
  Rendered vendor/bundle/ruby/2.2.0/gems/teaspoon-1.1.1/app/views/teaspoon/suite/_boot.html.erb (14865.5ms)
  Rendered vendor/bundle/ruby/2.2.0/gems/teaspoon-1.1.1/app/views/teaspoon/suite/_body.html.erb (0.3ms)
  Rendered vendor/bundle/ruby/2.2.0/gems/teaspoon-1.1.1/app/views/teaspoon/suite/show.html.erb (14941.8ms)
Completed 200 OK in 14950ms (Views: 14949.7ms | ActiveRecord: 0.0ms)
ReferenceError: Can't find variable: Teaspoon
  # /teaspoon/default?reporter=Console:12

ReferenceError: Can't find variable: Teaspoon
  # /teaspoon/default?reporter=Console:119

close: 127.0.0.1:52763
Failed to load: http://127.0.0.1:43627/teaspoon/default?reporter=Console
close TCPSocket(0.0.0.0, 43627)
going to shutdown ...

WEBrick::HTTPServer#start done. bundle exec teaspoon returned exit code 1
jejacks0n commented 8 years ago

Hmm.. I think this has shown up before, but I don't fully understand it, can't remember the resolution, and don't use CircleCI often.

What I would assume is that the teaspoon assets aren't available in whatever environment circleCI is running the specs within.. locally try running RAILS_ENV=test rake teaspoon, and see if you get the same results, we can work from there.

hakunin commented 8 years ago

Thanks for the speedy reply. RAILS_ENV=test rake teaspoon produces regular console output. I'll ask CircleCI guys since that might be issue created by them and report back.

The readme did say though that it runs smoothly with CircleCI, hopefully we'll be able to make it so.

jejacks0n commented 8 years ago

It's kinda rough to debug from this angle since the output is just kinda missing, because Teaspoon can't do much unless it's loading the javascript. haha.

I think it must have to do with the assets not being loadable in that environment, but don't understand why they wouldn't be. There's also a lot of causes for this -- a quick search in the issues results in some pretty hefty issue threads, and it seems to usually be related to rails not understanding that the teaspoon assets should be precompiled/available.

jejacks0n commented 8 years ago

It would be great to get a resolution from CircleCI. I'd love to have easy out of the box support for it if there's something that we can adjust.

hakunin commented 8 years ago

So I haven't heard back from CircleCI, but I stubled upon a precompile hint in their guides and now I am a little bit closer:

my circle.yml:

test:
  post:
    - bundle exec rake assets:precompile
    - bundle exec teaspoon

Ah, I thought I was getting a different error, but its the same one.

hakunin commented 8 years ago

I found the problem!!

I had set the domain attributes in test environments, which overrided where the server was looking for the assets, making it impossible to find them, because CircleCI doesn't run the server on localhost:3000.

So in theory, if you don't have that set in your project, it should run with CircleCI just fine.