久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

JSHint 認為 Jasmine 函數未定義

JSHint thinks Jasmine functions are undefined(JSHint 認為 Jasmine 函數未定義)
本文介紹了JSHint 認為 Jasmine 函數未定義的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有一個使用 Karma+Jasmine 和 JSHint 的 Grunt 設置.每當我在我的規范文件上運行 JSHint 時,我都會收到一系列未定義"錯誤,其中大部分是 Jasmine 的內置函數.例如:

I've got a Grunt setup which uses Karma+Jasmine and JSHint. Whenever I run JSHint on my spec file, I get a series of "undefined" errors, most of which are for Jasmine's built-in functions. For example:

Running "jshint:test" (jshint) task

   js/main.spec.js
      3 |describe("loadMatrix()", function() {
         ^ 'describe' is not defined.
      4 |    it("should not assign a value if no arg is passed.", function() {
             ^ 'it' is not defined.

(我的規范要測試的 JS 文件中的變量和函數也有一些未定義的錯誤,但我不確定這是為什么,這可能是一個單獨的問題.)

(I also get some undefined errors for the variables and functions from the JS file that my spec is meant to test against, but I'm not sure why that is and it may be a separate issue.)

我的 Karma 配置文件中有 frameworks: [ "jasmine" ],我沒有為 JSHint 設置任何全局變量,也沒有 .jshintrc 文件,因為我在 Grunt 中配置它.我曾嘗試將 Jasmine 的函數作為 JSHint 全局變量添加到我的 Gruntfile 中,但是將它們設置為 truefalse 并沒有什么不同——錯誤仍然存??在JSHint 跑了.

My Karma config file has frameworks: [ "jasmine" ] in it, I don't have any globals set for JSHint, and I don't have a .jshintrc file since I'm configuring it in Grunt. I did try adding Jasmine's functions as JSHint globals in my Gruntfile at one point, but setting them as either true or false didn't make a difference—the errors still persisted when JSHint ran.

我錯過了什么?我似乎無法讓 JSHint 在我的規范文件中跳過對 Jasmine 函數的定義檢查.

What am I missing? I can't seem to do anything to get JSHint to skip definition checking for Jasmine's functions in my spec file.

推薦答案

MINOR CORRECTION - .jshintrc 文件中的 predef 周圍應該有".

MINOR CORRECTION - there should be "" around predef in the .jshintrc file.

通過將其添加到我的 Gruntfile.coffee 中的 jshint 選項來修復:

Fixed by adding this to the jshint options in my Gruntfile.coffee:

predef: [
    "jasmine"
    "describe"
    "xdescribe"
    "before"
    "beforeEach"
    "after"
    "afterEach"
    "it"
    "xit"
    "it"
    "inject"
    "expect"
    "spyOn"
]

.jshintrc:

"predef": [
    "jasmine",
    "describe",
    "xdescribe",
    "before",
    "beforeEach",
    "after",
    "afterEach",
    "it",
    "xit",
    "it",
    "inject",
    "expect",
    "spyOn",
]

這篇關于JSHint 認為 Jasmine 函數未定義的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 精品免费在线 | 夜夜爽99久久国产综合精品女不卡 | 亚州综合一区 | a亚洲精品 | 国产精品视频一区二区三区 | 91视频大全 | 亚洲久久一区 | 国产在线看片 | 不用播放器看的av | 日韩在线播放视频 | 久久精品黄色 | 综合色播 | 国产99久久精品一区二区永久免费 | 成人国产精品久久久 | 先锋资源在线 | 99re在线免费视频 | 久久久久亚洲av毛片大全 | 国产激情91久久精品导航 | 日韩欧美一二三区 | 欧美在线视频观看 | 久色视频在线 | 亚洲h色 | 亚洲成色777777在线观看影院 | 国产一区2区 | 国产亚洲第一页 | 国产在线中文字幕 | 中国一级特黄真人毛片 | 伊人久久大香线 | 在线观看中文字幕 | 国产乱码精品一区二区三区中文 | 国产婷婷色一区二区三区 | 五月婷婷婷 | 国产一区二区三区在线视频 | 色视频在线观看 | 亚洲美女一区 | 国产精品一区二区在线 | 欧美a级成人淫片免费看 | 国产高清一区二区 | 日本综合在线观看 | 亚洲精品久久久9婷婷中文字幕 | 欧美性tv |