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

2

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
+-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | |   +-- [email protected]
| | |   `-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | +-- [email protected]
| | | `-- [email protected]
| | |   +-- [email protected]
| | |   `-- [email protected]
| | `-- [email protected]
| +-- [email protected]
| +-- [email protected]
| | +-- [email protected]
| | `-- [email protected]
| +-- [email protected] extraneous
| +-- [email protected] extraneous
| +-- [email protected] extraneous
| +-- [email protected]

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

Xenophobia answered 20/8, 2016 at 20:37 Comment(1)
What IDE are you using?Pulitzer
M
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
Mathura answered 20/8, 2016 at 21:32 Comment(11)
tsd install jasmineXenophobia
'tsd' is not recognized as an internal or external command, operable program or batch file.Xenophobia
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.Mathura
Thanks for the quick help now this second command "tsd install jasmine "got installed.Xenophobia
now i have another issue when i try this command " tsd install jasmine"Xenophobia
below is error that i got when i tried " tsd install jasmine "Xenophobia
C:\>tsd install jasmineXenophobia
[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"Xenophobia
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: github.com/DefinitelyTyped/tsd/issues [ERR!] tsd.json could not be retrieved [ERR!] .tsdrc could not be retrievedXenophobia
I hope its something related to certificate issue because i am working on a secured VM with restricted rights.Xenophobia
you can do it in two way.. 1st and better way, create a tsdrc file and provide your proxy and other settings there.. github.com/Definitelytyped/tsd#tsdrc the other way, just copy the jasmine.d.ts file from github.com/DefinitelyTyped/DefinitelyTyped/blob/master/jasmine/… (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.Mathura
H
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

Hark answered 22/8, 2016 at 11:57 Comment(2)
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.Mathura
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 matchersXenophobia

© 2022 - 2024 — McMap. All rights reserved.