如何让WebStorm识别Jasmine方法? [英] How can I get WebStorm to recognize Jasmine methods?

查看:254
本文介绍了如何让WebStorm识别Jasmine方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 node.js 项目,其中包含一些茉莉花规格。规范位于spec /子目录中,并具有.spec.coffee扩展名,如 jasmine-node 所示。

I have a node.js project that contains some Jasmine specifications. The specifications are in a spec/ subdirectory and have the .spec.coffee extension, as required by jasmine-node.

当我在 WebStorm IDE中打开我的一个规范文件时,所有调用 beforeEach 描述 it 蓝色波浪形用工具提示下划线:未解决的函数或方法it()。即使我正在使用 3.0 EAP ,它应该有一定数量的Jasmine支持,它不会自动发现这是一个茉莉花规格文件。

When I open one of my spec files in the WebStorm IDE, all the calls to beforeEach and describe and it are shown with blue squiggly underlines with the tooltip: "Unresolved function or method it()". So even though I'm using the 3.0 EAP and it's supposed to have some amount of Jasmine support, it's not automatically picking up on the fact that this is a Jasmine spec file.

我尝试进入文件>设置> JavaScript库,并添加Jasmine作为库(指定jasmine-2.0.0.rc1.js的路径),然后转到Usage Scope子页面并检查Project旁边的下拉列表中的Jasmine,但这没有效果 - Jasmine方法仍然显示为未解析。

I tried going into File > Settings > JavaScript Libraries, and adding Jasmine as a library (specifying the path to jasmine-2.0.0.rc1.js), and then going to the Usage Scope sub-page and checking "Jasmine" in the drop-down list next to "Project", but that had no effect -- the Jasmine methods still show up as unresolved.

我如何告诉WebStorm spec子目录中的所有文件和/或扩展名为.spec.coffee的所有文件都是Jasmine测试,并让它识别那些测试正在使用的Jasmine API?

How can I tell WebStorm that all files in a spec subdirectory, and/or all files with a .spec.coffee extension, are Jasmine tests, and have it recognize the Jasmine APIs those tests are using?

推荐答案

您可以在Webstorm / PHPStorm / I中使用预定义的JS库存根dea

You can use predefined JS library stubs in Webstorm/PHPStorm/Idea


  • 打开文件>设置...

  • 选择语言&框架> JavaScript>图书馆

  • 点击下载...

  • Open File > Settings...
  • Select Languages & Frameworks > JavaScript > Libraries
  • Click on Download...


  • 切换到 TypeScript社区存根

  • 查找 karma-jasmine (最初名称 jasmine )(如果这不起作用,请尝试 jasmine

  • 点击下载并安装

  • Swich to TypeScript community stubs
  • Find karma-jasmine (originally under the name jasmine) (If this does not work, try jasmine instead)
  • Click on Download and Install

我在Jasmine 2.0中使用此设置

I am using this setup with Jasmine 2.0

这篇关于如何让WebStorm识别Jasmine方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆