Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
595 views
in Technique[技术] by (71.8m points)

jasmine - How to integrate Protractor test cases in Atom using Typescript?

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

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

I wrote in this structure.

 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');
  });
});

I am getting following errors.

erros

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

I went through: 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.

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?

Please guide me..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

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

import {browser} from 'protractor/globals';

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...