0

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Balaji Singh .Y
  • 683
  • 2
  • 9
  • 22

2 Answers2

0

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
TypeScripter
  • 879
  • 2
  • 10
  • 23
  • tsd install jasmine – Balaji Singh .Y Aug 21 '16 at 17:58
  • 'tsd' is not recognized as an internal or external command, operable program or batch file. – Balaji Singh .Y Aug 21 '16 at 17:58
  • sure, I assumed that you have tsd installed. try "npm install -g tsd". This will install tsd globally and then you can try tsd install jasmine. – TypeScripter Aug 22 '16 at 00:18
  • Thanks for the quick help now this second command "tsd install jasmine "got installed. – Balaji Singh .Y Aug 27 '16 at 13:37
  • now i have another issue when i try this command " tsd install jasmine" – Balaji Singh .Y Aug 27 '16 at 13:38
  • below is error that i got when i tried " tsd install jasmine " – Balaji Singh .Y Aug 27 '16 at 13:40
  • C:\>tsd install jasmine – Balaji Singh .Y Aug 27 '16 at 13:45
  • [ERR!] cwd : C:\[ERR!] cwd : C:\ [ERR!] os : Windows_NT 6.1.7601 [ERR!] argv : "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\x216526\\AppData\\Roaming\\npm\\node_modules\\tsd\\build\\cli.js" "install" "jasmine" [ERR!] os : Windows_NT 6.1.7601 [ERR!] argv : "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\x216526\\AppData\\Roaming\\npm\\node_modules\\tsd\\build\\cli.js" "install" "jasmine" – Balaji Singh .Y Aug 27 '16 at 13:50
  • ERR!] node : v5.6.0 [ERR!] tsd : 0.6.5 [ERR!] Error: unable to get local issuer certificate [ERR!] CODE : UNABLE_TO_GET_ISSUER_CERT_LOCALLY [ERR!] unable to get local issuer certificate [ERR!] If you need help, you may report this error at: https://github.com/DefinitelyTyped/tsd/issues [ERR!] tsd.json could not be retrieved [ERR!] .tsdrc could not be retrieved – Balaji Singh .Y Aug 27 '16 at 13:52
  • I hope its something related to certificate issue because i am working on a secured VM with restricted rights. – Balaji Singh .Y Aug 27 '16 at 13:53
  • you can do it in two way.. 1st and better way, create a tsdrc file and provide your proxy and other settings there.. https://github.com/Definitelytyped/tsd#tsdrc the other way, just copy the jasmine.d.ts file from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/jasmine/jasmine.d.ts (either download or copy content and paste in a file which is named jasmine.d.ts).. when you follow this second approach, you don't need tsd, so you can skip tsd related steps, do refer that new file as explained above. – TypeScripter Aug 27 '16 at 23:45
0

@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 -

Jasmin version

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

matchers

Ram Pasala
  • 4,931
  • 3
  • 16
  • 26
  • I doubt if he wants that, As the question mentions, when he types dot, after that, methods (matchers) like toBe() are not appearing as part of intellisense. – TypeScripter Aug 22 '16 at 20:06
  • Thanks for all who pitched in . I understand this pacakge.json and Jasmine.js which contains all these matchers. But i dont know why iam not able to see any matchers like "toBE " after dot. I dont see that various listing matchers – Balaji Singh .Y Aug 27 '16 at 13:32