如何使用 Typescript 在 Atom 中集成 Protractor 测试用例? [英] How to integrate Protractor test cases in Atom using Typescript?

查看:21
本文介绍了如何使用 Typescript 在 Atom 中集成 Protractor 测试用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为 atom 安装了 typescript,用于编写用于自动化的量角器脚本.

I have installed typescript for atom for writing Protractor Scripts For automation.

我的代码是用 Jasmine 框架编写的,因为量角器很好地支持它.

My code is written in Jasmine Framework as protractor supports it nicely.

我用这种结构写的.

 describe('Sign in',function(){
     it ('Verify Modules Present', function(){
     loginPage.enterUsernameAndPasswordWithSignIn('a','b');
     browser.sleep(3000);
     var module = element(by.xpath("//*[@ng-reflect-router-link='My']"));
     browser.wait(protractor.ExpectedConditions.elementToBeClickable(module),
                                  8000).thenCatch(function () {
              assert.fail(' element is not click able');
      });
    var expectedModuleName = ["My", "X","Y", "Z" ];
    var testArray = ["My", "X","Y", "Z" ];;
    logger.log('info','Checking All modules');
    for (var i = 0; i < testArray.length;i++) {
      var moduleName = text.verifyText("//*[@ng-reflect-router-link='"+ testArray[i] + "']");
      expect(moduleName).toBe(expectedModuleName[i]);
    }
  logger.log('info','Checked All modules');
  });
});

我收到以下错误.

我的理解是:Typescript 无法找到 Jasmine 库.怎么做?

My understanding is : The Typescript is not able to find Jasmine libraries. How to do so?

我经历了: https://angular.io/docs/ts/latest/testing/jasmine-testing-101.html

但是找不到太多.我也安装了打字机.但我不知道如何使用它.

But couldn't find much. I installed typings too. But I don't know how to use it.

如何将 Jasmine Framework 配置为 Protractor 的 atom 以解决此错误?

How can i configure Jasmine Framework into atom for Protractor so that this errors may resolve?

如果不是这样,哪个编辑器可以用于这样做以及如何使用?

If not so, Which editor can be useful to do so and how?

请指导我..

推荐答案

您必须安装 jasminenode 类型,以便 typescript 识别它们.现在有更好的方法,不需要typings 文件夹和typings.json.我们有相同的 @types 依赖项.

You have to install jasmine and node typings so that typescript recognizes them. Now there is even a better approach, there is no need of typings folder and typings.json. we have @types dependencies for the same.

所以你可以通过以下步骤来做到这一点-

so you can do that by following steps-

转到您的项目文件夹并安装依赖项 -

go to your project folder and install the dependencies -

 npm install --save-dev @types/jasmine //this would install jasmine typings as a dev dependency in your package.json
 npm install --save-dev @types/node   //this would install node typings as a dev dependency in your package.json

安装后尝试使用 tsctsc -w 监视模式编译它,现在您应该不会看到那些 TS 语法错误!

once you have installed try compiling it with tsc or tsc -w watch mode, now you shouldn't see those TS syntax errors!

你必须从 protractor/globals 导入 browser 来使用它的方法,就像这样-

And you have to import browser from protractor/globals to use its methods, like this-

import {browser} from 'protractor/globals';

有关更多详细信息,您可以查看我的代表以了解 带有打字稿的量角器它使用黄瓜,您可以查看官方 protractor-typescript 示例

For more details you can check out my rep for initial setup of protractor with typescript it uses cucumber as well as you can check out the official protractor-typescript example

这篇关于如何使用 Typescript 在 Atom 中集成 Protractor 测试用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆