jejacks0n / teaspoon

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

Error after upgrading to 1.0.x: Can't find variable: Teaspoon #397

Closed arthurnn closed 9 years ago

arthurnn commented 9 years ago

upgrading from 0.9.1 to 1.0.2 gives this error:

Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on 0.0.0.0:5000, CTRL+C to stop
Teaspoon running foobar suite at http://127.0.0.1:5000/teaspoon/foobar
ReferenceError: Can't find variable: Teaspoon
  # http://127.0.0.1:5000/teaspoon/foobar?reporter=Console:14

ReferenceError: Can't find variable: Teaspoon
  # http://127.0.0.1:5000/teaspoon/foobar?reporter=Console:143

I wish I could provide more info, but I am not sure how/where to get a stacktrace of the error, also not sure if there is a verbose mode or something that could give me more info to debug the problem.

thanks

mikepack commented 9 years ago

Does this happen when run in your browser with /teaspoon? You can access a stack trace from there. Have you followed the upgrade notes?

arthurnn commented 9 years ago

Does this happen when run in your browser with /teaspoon

Nop, on the browser it works just fine.

mikepack commented 9 years ago

Have you followed the upgrade notes?

arthurnn commented 9 years ago

Have you followed the upgrade notes?

yep.

mikepack commented 9 years ago

Phantom is a black box, which makes debugging issues like this difficult.

I see you're using thin on port 5000. Can you please provide any other details specific to how you're running teaspoon CLI?

Worth trying: bundle open teaspoon and put a debugger/pry after this line to pause the teaspoon CLI. Grab the URL it provides you and open that in your browser.

mikepack commented 9 years ago

Can you please post the contents of your teaspoon_env.rb file?

arthurnn commented 9 years ago

I dont work for Shopify anymore, so I dont have access to the file. @rafaelfranca can you help out here?

rafaelfranca commented 9 years ago

I upgraded teaspoon some weeks ago. Let me see if this issue still happen and I'll provide the file. @arthurnn thank you for the heads up.

rafaelfranca commented 9 years ago

Yeah, it still happen but only locally, not in the CI. Here is the content of the file:

# Set RAILS_ROOT and load the environment if it's not already loaded.

unless defined?(Rails)
  ENV['RAILS_ENV']='test'
  ENV["RAILS_ROOT"] = File.expand_path("../../", __FILE__)
  require File.expand_path("../../config/environment", __FILE__)
end

# Load mocha, so we can use stubs on magic lamps
require 'mocha/setup'

Teaspoon.configure do |config|
  config.mount_at = "/teaspoon"
  config.root = nil
  config.asset_paths = ["test/javascripts"]
  config.fixture_paths = ["test/javascripts/fixtures"]
  config.asset_manifest += [/^unit\//, /teaspoon/, /mocha/, /test_suite_polyfills/]

  config.suite(:default) do |suite|
    suite.expand_assets = false
    suite.use_framework :mocha
    suite.matcher = "{test/javascripts,app/assets}/**/*_test.{js,js.coffee,coffee}"
    suite.helper = "test_helper"
    suite.stylesheets = ["teaspoon"]
  end

  config.asset_manifest += Teaspoon::Suite.all.map { |suite| "#{suite.helper}.js" }

  config.server_port=5000

  config.coverage do |coverage|
    coverage.ignore = [%r{/lib/ruby/gems/}, %r{/vendor/assets/}, %r{/support/}, %r{/(.+)_helper.}]
  end
end
rafaelfranca commented 9 years ago

Ok. Now I know the reason of the error. Teaspoon starts the server with bind only in 127.0.0.1. This doesn't work for our case because we access our assets using the local CDN that don't use the loopback interface.

@mikepack would you accept a PR to configure the Rack server host so we can bind to 0.0.0.0?

mikepack commented 9 years ago

@rafaelfranca absolutely. The port is configurable, so it should be pretty easy follow that pattern.

jejacks0n commented 9 years ago

Yeah, my oversight -- haven't had that sort of setup before, but seems reasonable.

rafaelfranca commented 9 years ago

:+1: I'll work on it