问题描述
我的项目正在从独立项目转向 Web,我们的新网站是在 AngularJS 中创建的,因此 Protractor 是为测试自动化选择的工具.
我想将 Typescript 与 Jasmine 和 Node 的依赖项集成,这样我就不会收到诸如
之类的错误找不到名字 描述找不到名字找不到名字 期待
谁能告诉我如何添加 Jasmine 和 Protractor 依赖项,以便当我按 ctrl + 空格键时,我将获得所有可用选项.
我已经安装了 Typescript.而且我得到了量角器依赖项,例如浏览器、元素、by 等.
我应该怎么做描述,它,期望(茉莉花的东西)?
我每天都使用 Visual Studio Code 来编写我的脚本,它是我目前最喜欢的 Protractor 编辑器,因为它内置了对 TypeScript 的支持!
以下是我想到的可以帮助您设置框架的内容-
- 下载最新的 VS Code 版本 - 保存您的文件并重新启动 VSCode 现在您可以开始了:)
My project is going from standalone to Web, Our new WebSite is getting created in AngularJS so Protractor is the tool selected for Test Automation.
I want to Integrate Typescript with dependencies of Jasmine and Node so that I don't get errors such as
cannot find name Describe cannot find name it cannot find name Expect
Can Anyone tell me how to add Jasmine and Protractor dependencies, so that when I hit ctrl + space i'll get all options available.
I have installed Typescript. And I am getting protractor dependencies such as browser, element, by etc.
What should i do for describe,it,expect (Jasmine stuffs) ?
解决方案I use Visual Studio Code everyday to write my scripts, it's my current favourite editor for Protractor because of its built in support for TypeScript!
Here are the following things which can come into my mind which could help you setup your framework-
- Download the latest VS Code version - https://code.visualstudio.com/download
- Install typescript globally
npm install -g typescript
- Install protractor globally
npm install -g protractor
- Create your project folder
Setup you project folder for git, node and typescript -
npm init -f // will create default package.json stating its nodejs project git init // will create .git file, you project is now git project tsc --init // will create tsconfig.json stating its typescript project
Install typings and dev dependencies-
npm install --save-dev protractor // this will install protractor as a dev dependency npm install --save-dev typescript // this will install typescript as a dev dependency npm install --save-dev @types/jasmine // jasmine typings npm install --save-dev @types/node // node typings
- At this point you have setup your basic
protractor-typescript
project and you can see all the typings and dependencies inpackage.json
. Now you are good to write your typed scripts :). Now compile your scripts by running -
tsc or tsc -w
- After successfull compilation all your javascript files would be generated.
The run protractor
protractor config.js
- You can also setup your vs code for debugging with protractor which I have mentioned here - Protractor -VS Code Debugging
For more details pls refer the TypeScript Tutorial, Protractor API
The Typescript error you are observing this is due to VS Code not recognizing global typescript 2.0 version.
To solve this open vscode go to preferences--> user settings --> settings.json will be opened and enter the highlighted path as shown
Save your file and restart VSCode now you are good to go :)
这篇关于如何在 Visual Studio Code 中使用 Typescript 和 Jasmine 框架编写 Protractor 测试脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!