Why I am not able be see any expect methods like .toBe () in Protractor?

强颜欢笑 提交于 2019-12-25 05:02:03

问题


Why I am not able to see any methods for expect in protractor?

For example when use expect in protractor like below

expect(true).toBe(true); 

After the dot I don't find any method as shown above toBe()

C:\>npm -g list
C:\Users\x216526\AppData\Roaming\npm
+-- protractor@4.0.3
| +-- adm-zip@0.4.7
| +-- chalk@1.1.3
| | +-- ansi-styles@2.2.1
| | +-- escape-string-regexp@1.0.5
| | +-- has-ansi@2.0.0
| | | `-- ansi-regex@2.0.0
| | +-- strip-ansi@3.0.1
| | `-- supports-color@2.0.0
| +-- glob@7.0.5
| | +-- fs.realpath@1.0.0
| | +-- inflight@1.0.5
| | | `-- wrappy@1.0.2
| | +-- inherits@2.0.1
| | +-- minimatch@3.0.3
| | | `-- brace-expansion@1.1.6
| | |   +-- balanced-match@0.4.2
| | |   `-- concat-map@0.0.1
| | +-- once@1.3.3
| | `-- path-is-absolute@1.0.0
| +-- jasmine@2.4.1
| | +-- exit@0.1.2
| | +-- glob@3.2.11
| | | `-- minimatch@0.3.0
| | |   +-- lru-cache@2.7.3
| | |   `-- sigmund@1.0.1
| | `-- jasmine-core@2.4.1
| +-- jasminewd2@0.0.9
| +-- optimist@0.6.1
| | +-- minimist@0.0.10
| | `-- wordwrap@0.0.3
| +-- protractor-html-screenshot-reporter@0.0.21 extraneous
| +-- protractor-jasmine2-html-reporter@0.0.6 extraneous
| +-- protractor-jasmine2-screenshot-reporter@0.2.0 extraneous
| +-- q@1.4.1

Please also tell me if their is any direct command to find the Jasmine version just like protractor --version.


回答1:


In order to see jasmine related functions you should have Jasmine type definitions. Do it as follows... first install typings globally as

npm install typings --global

now install jasmine type definitions

tsd install jasmine

Next put a reference of type definition file in your typescript test file in below manner.

/// <reference path="../../typings/main/ambient/jasmine/jasmine.d.ts" />

(note, path may be different based on where it is installed, correct it accordingly)

After this, you should be able to use all Jasmine matchers.

Regarding Jasmine version - I can see in your package.json it say Jasmine 2.4.1. So, 2.4.1 is the version. If you want to confirm it then use following command

npm view jasmine version



回答2:


@Balaji, If I understood the question correctly you want to see the expect methods like toBe inside protractor? you can check it inside your global protractor folder, in your case open C:\Users\x216526\AppData\Roaming\npm/protractor4.0.3

  • You can check the Jasmine version in package.json -

  • You can find the jasmine matchers i.e expect methods toBe inside the node_modules in jasmine core like this-



来源:https://stackoverflow.com/questions/39058504/why-i-am-not-able-be-see-any-expect-methods-like-tobe-in-protractor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!