svp
svp

Reputation: 495

Protractor:Configure Protractor with RequireJs

I am using protractor tests for my angularjs app.Currently i am using browser.executeAsyncScript to inject $http into protractor tests.

browser.executeAsyncScript(function(callback){
      $http = angular.injector(["ng"]).get("$http");      
});

Can i use requirejs with protractor which loads angular for me??Can anyone help me on how to configure protractor with requirejs???

Thank you.

Upvotes: 0

Views: 271

Answers (1)

Kieran Ryan
Kieran Ryan

Reputation: 591

typically you would use the angular inject method to reference the $http Service, or $compile or $rootScope etc. etc. as follows:

describe('Backend', function(){
    var http;
    beforeEach(inject(function($http){
        http = $http;
    }));
    it('should be available', function(){
       http({
           method: 'GET',
           url: 'http://cms.acme.ch/app#index.html',
           data: 
               {
                   token: 'aAxXx2907-Tuy233bb?//'
               } 
           })
           .onSuccess(function(){
               expect(true).toBeTruthy();
           })
           .onError(function(){
               expect(true).toBeFalsy();
           });

    });
});

Upvotes: 1

Related Questions