jejacks0n / teaspoon

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

How do I set this up to work with Qunit? #245

Closed zwarburg closed 10 years ago

zwarburg commented 10 years ago

The app I have been tasked with working with already has a bunch of Qunit tests in place. I added the teaspoon_env.rb file with:

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

Teaspoon.configure do |config|
  config.mount_at = "/teaspoon"
  config.asset_paths = ["test/javascripts", "test/javascripts/stylesheets"]
  config.suite do |suite|
    suite.use_framework :qunit
    suite.matcher = "{test/javascripts/ember_test,app/assets/javascripts}/**/*.{js,js.coffee,coffee}"
    suite.helper = "/test/javascripts/ember-qunit.js"
    suite.javascripts = ["qunit/1.14.0", "teaspoon-qunit"]
  end
  config.driver = "phantomjs"
  config.coverage do |coverage|
  end
end

but the tests still don't work. What am I missing? What else do I need to do?

zwarburg commented 10 years ago

I could really use some help on this.

jejacks0n commented 10 years ago

Use the same version of qunit that you were using? Covered in the readme on how to do this.


Jeremy Jackson

On Jul 11, 2014, at 12:10 PM, Zack Warburg notifications@github.com wrote:

I could really use some help on this.

— Reply to this email directly or view it on GitHub.

zwarburg commented 10 years ago

@jejacks0n I think part of the problem may be that the app doesn't directly use qunit. It uses qunit-rails. I am not just asking for help after 5 minutes of trying. I've been at this for days. Any help would be so appreciated.

zwarburg commented 10 years ago

The current error message I am getting is (and this is just a small snippet of it...

~$ rake teaspoon
(in /Users/zwarburg/src/production)
Starting the Teaspoon server...
Teaspoon running default suite at http://127.0.0.1:61414/teaspoon/default
DEBUG: -------------------------------
DEBUG: Ember      : 1.7.0-beta.1+canary.d047abcf
DEBUG: Ember Data : 1.0.0-beta.9+canary.e9cf0016
DEBUG: Handlebars : 1.3.0
DEBUG: jQuery     : 1.10.2
DEBUG: -------------------------------
generated -> route:application [object Object]
generated -> route:index [object Object]
generated -> controller:application [object Object]
Could not find "application" template or view. Nothing will be rendered [object Object]
generated -> controller:index [object Object]
Could not find "index" template or view. Nothing will be rendered [object Object]
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Failures:

  1)  global failure (1, 0, 1)
     Failure/Error: SyntaxError: Parse error

  2)  global failure (1, 0, 1)
     Failure/Error: ReferenceError: Can't find variable: moduleForComponent

  3)  global failure (1, 0, 1)
     Failure/Error: ReferenceError: Can't find variable: moduleForComponent

The moduleForComponent call is being made from the first test in test/javascripts/ember_test/components/auto-complete.js.coffee

moduleForComponent 'auto-complete', 'component:auto-complete',
  setup: ->
    window.dollarSign = window.$
    window.$ = (object) -> object
  teardown: ->
    window.$ = window.dollarSign
    App.reset()

moduleForComponent is defined in the ember-qunit.js file at test/javascripts/ember-qunit.js. I explicitly included this file in the config so I don't understand why it isn't being found.

As a side note all of these test pass when just using qunit by going to localhost:3000/qunit

zwarburg commented 10 years ago

Anybody willing to help?

bj-mcduck commented 10 years ago

@zwarburg Did you get any further with this? I'm just getting my toes wet as well with Ember/Teaspoon/Qunit.

cameronlinden commented 9 years ago

@zwarburg did you ever figure this out? I also had a very similar error.

mgharbik commented 9 years ago

I had the same error but now it seemed like it works well, in spec_helper.js files I removed all the lines was generated automatically and kept only my setup. Hope this helps!