2014-01-25 27 views
6

我正在做一個小型玩具項目來測試Yeoman和角度。在Yo生成的Angular項目中跳過測試

在創建應用程序yo angular後,我開始編寫服務及其測試。直到我試圖忽略一個測試,一切都是完美的。

從我讀過的書中,我應該可以忽略一個將it更改爲xit並將套件更改describe更改爲xdescribe的測試。

但是,當我保存和grunt啓動測試時,我得到一個'xit' is not defined'xdescribe' is not defined錯誤。

有什麼我失蹤了嗎?

+1

開'Gruntfile.js'在年底找到'grunt.registerTask( '默認',[ '更新:jshint', 「測試', 'build' ]);'當你需要測試使用'grunt test'時,'移除'test'行。 –

+0

改變你的建議之後,它會一直失敗,但無論如何,我不想禁用'jshint'。 –

+0

我遇到同樣的問題。即使在'.jshintrc'文件中添加'xdescribe'和'xit',它仍然會引發錯誤。我的項目也是一個'角生成器'的應用程序。 – jedmao

回答

4

您需要編輯或可能創建一個名爲.jshintrc文件,你就會有這樣的事情:

 
{ 
    "curly": false, 
    "eqeqeq": false, 
    "immed": true, 
    "latedef": true, 
    "newcap": true, 
    "noarg": true, 
    "sub": true, 
    "undef": true, 
    "boss": true, 
    "eqnull": true, 
    "browser": true, 
    "es5":true, 
    "smarttabs": true, 
    "expr":true, 
    "globals": { 
     "angular": true, 
     "console": true, 
     "expect" : true, 
     "inject" : true, 
     "describe" : true, 
     "beforeEach" : true, 
     "it" : true, 
     "xit" : true, 
     "xdescribe": true 
    } 
} 

通知下全局的XIT和xdescribe。

在你gruntfile去jshint任務,並將此

 
jshint: { 
     options: { 
     jshintrc: '.jshintrc' 
     } 
} 
+0

這可能是應用程序生成中的錯誤嗎? –

+0

我真的不明白你的問題。 來自jshint文檔: JSHint帶有一組默認的警告,但它被設計爲非常易於配置。有三種主要的方法來配置您的JSHint副本:您可以通過--config標誌手動指定配置文件,使用特殊文件.jshintrc或將您的配置放入jshintConfig屬性下的項目package.json文件中。 – TestersGonnaTest

+0

是的,我知道可以配置jsHint,但似乎很奇怪Yeoman生成的應用程序沒有可能忽略測試。 –