簡體   English   中英

為什么茉莉花沒有運行我的任何規格?

[英]Why isn't jasmine running any of my specs?

我在我的Gemfilegroup :development, :test )中添加了Gemfile gem 'jasmine', '~> 2.0.0'並運行了生成器rails g jasmine:install Gemfile rails g jasmine:install

我有一個簡單的規范

# spec/javascripts/truth_spec.js 
describe("Truth", function() {
  it("herps the derps", function() {
    expect(true).toEqual(true);
  });
});

當我運行rake jasmine我得到正常輸出:

your server is running here: http://localhost:8888/
your tests are here:         /Users/jared/git/givegab/spec/javascripts
your source files are here:  /Users/jared/git/givegab

>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:8888, CTRL+C to stop

我在瀏覽器中打開http://localhost:8888/ ,我得到一個空白的灰色屏幕 我的JS控制台是空的,沒有錯誤,當我使用調試器跟蹤執行時, 我可以單步執行boot.jsjasmine.js 沒有錯誤。

我可以在truth_spec.js設置一個調試器斷點,它永遠不會被命中。

這是我第一次使用茉莉花,所以請假設我遺漏了一些明顯的東西

如果正確設置了jasmine,那么在瀏覽器中打開http://localhost:8888/jasmine應運行所有規范。

您還可以使用以下命令運行特定規格:

http://localhost:8888/jasmine?spec=herps the derps

如果要使用交互式Web版本,請確保在config/initializers/有一個名為jasminerice.rb的文件,其中包含以下內容:

# Use this file to set configuration options for Jasminerice, all of these are initialized to their respective defaults,
# but you can change them here.
if defined?(Jasminerice) == 'constant'
  Jasminerice.setup do |config|
    # Tell Jasminerice to automatically mount itself in your application. If set to false, you must manually mount the
    # engine in order to use Jasminerice.
    #config.mount = true

    # If automatically mounting Jasminerice, specify the location that it should be mounted at.  Defaults to /jasmine, so
    # you could access your tests at http://YOUR_SERVER_URL/jasmine
    #config.mount_at = '/jasmine'

    # Specify a path where your fixutures can be found. Defaults to 'spec/javascripts/fixtures'
    #config.fixture_path = 'spec/javascripts/fixtures'
  end
end

務必在之后重新啟動rails服務器。 此初始化程序在運行時為jasmine Web視圖設置路由,因此如果運行rake routes | grep jasmine rake routes | grep jasmine ,你應該看到以下內容:

jasminerice /jasmine Jasminerice::Engine GET /spec/:spec_id/fixtures/*filename(.:format) jasminerice/spec#fixtures spec_index GET /spec(.:format) jasminerice/spec#index GET /fixtures/*filename(.:format) jasminerice/spec#fixtures GET /(:suite)(.:format) jasminerice/spec#index

我的同事找到了根本問題。 令我們非常尷尬的是,我們覆蓋了window.onload 我想不出任何方式茉莉(或SO)可以找出這樣一個愚蠢的錯誤。 感謝您抽出寶貴時間幫我們排除故障。

寶石作者ragaskar 幫助我們解決了這個問題 ,並給了我們一些很好的建議。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM