如何關閉 WebStorm 的 Jasmine Warning ?
關閉 WebStorm 惱人的警告訊息
使用 WebStorm 寫 Protractor 或 Jasmine 測試時,有 2 個 WebStorm 的 warning 會造成困擾,建議將其關閉。
Version
WebStorm 2017.2.2
Symptom

Jasmine 的 toBe() 會出現 warning。
因為 toBe() 回傳的是 promise,WebStorm 是警告應該有
then()作相對的處理,其本意是好的,不過在寫測試時,一般不會再去寫then()。

在 Protractor 的 page object 內,method 會出現 warning。
由於 page object 的 method 都沒使用到 field,會被警告可以改用 static methhod。
Recipe
Promise

File ->Settings -> Editor ->Inspections -> JavaScript -> Probable bugs
Result of method call returning a promise is ignored 不要勾選。

ToBe() 就不再出現 warning 了。
Static

File ->Settings -> Editor ->Inspections -> JavaScript -> General
Method can be static 不要勾選。

Page object 內的 method 就不再出現 warning 了。
Conclusion
- WebStorm 這 2 個 warning 都是善意的,只是一般在寫測試時,這 2 個 warning 對我們並沒有幫助,因此可以暫時關閉。