Visual Studio 2013 protractor intellisense

2019-04-15 05:43发布

问题:

First of all, I am very beginner in using node.js / angualar.js /protractor.js and jasmine.js stuff and I am not from web dev corner at all. But for now, I just want to create some protractor test for an angular app and this is actually working quite fine. But I am wondering if it's possible to get VS2013 intellisense working? I would really appreciate if VS would suggest functions of objects like 'browser.xxx'. I am really stuck with that, looking forward for some hints!

thx Florian

回答1:

Ill just give an answer to myself! To get Visual Studio 2013 intellisense and debugging working for angular protractor tests, follow these steps:

  1. Install node.js
  2. Install protractor (global) („npm install -g protractor“; „webdriver-manager update“)
  3. Install Visual Studio 2013 node.js Tools
  4. Install Visual Studio 2013 TypeScript Tools

  1. Create a new project „Typescript\Node.js\Blank Node.js Console Application“
  2. Add your „conf.ts“ and „spec.ts“ files to the project
  3. Right click on „conf.ts“ and select „Set as node.js startup file“
  4. In „Project properties“ set your „Node.exe path“ to your protractor executeable file, eg. „C:\Users\myUser\AppData\Roaming\npm\protractor.cmd“

  1. Download typescript DefinitelyTyped definitions from git hub:
    • https://github.com/borisyankov/DefinitelyTyped
  2. In your VS2013 project folder „Scripts\Typing“ create the subfolders „jasmine“, „protractor“ and „selenium-webdriver“
  3. Add the typing definition files "angular-protractor\angular-protractor.d.ts", "jasmine\jasmine.d.ts" and "selenium-webdriver\selenium-webdriver.d.ts" into the appropriate project folders you created in the step above.

  1. Write your protractor test and enjoy code highlighting
  2. Start webdriver-manger „webdriver-manager start“
  3. Hit „F5“ to start debugging

Enjoy! Florian