Protractor `addMockModule ()` with arguments that does not properly handle structured data in Firefox

I recently read about solving these protractor problems:

  • Can't easily pass context in addMockModule

    # 695
  • feat (addMockModule): add third parameter to transfer context # 787

I was very eager to dry my protractor tests and this was the solution I needed. This solution works fine with ChromeDriver, but it's strangely broken with FirefoxDriver. Here's my code (in a block beforeEach()

:

  var httpBackendMock = function() {
      angular.module('httpBackendMock', ['ngMockE2E'])
        .value('mockData', arguments[0])
        .run(function ($httpBackend, mockData) {
          $httpBackend.whenGET(/.*aggregates/)
            .respond(200, mockData.testAggregates);
          $httpBackend.whenGET(/.*merchants\/123456/)
            .respond(200, mockData.testMerchant);
        });
  };
  browser.addMockModule('httpBackendMock', httpBackendMock, {
    testAggregates: testAggregates,
    testMerchant: testMerchant
  });

      

( testAggregates

and testMerchant

defined earlier.)

This works fine in Chrome, but in Firefox when the wait fire whenGET

does not return data. It fails if I use object mockData

or use directly arguments[0]

.

But it gets weirder. If I try to check the value of the module mockData

that was created above in the next call browser.executeScript()

, there is data there and console.log

displays it in the same way in both Chrome and Firefox.

  browser.get('index.html#/experiments');
  browser.executeScript(function() {
    return angular.injector(["httpBackendMock"]).get('mockData');
  }).then(function(data) {
    console.log("DATA", data);
  });

      

When the test runs, the data is displayed as expected.

The only workaround for this I found was the JSON.stringify()

in addMockModule()

and out entrance JSON.parse()

. It seems to work, but ugly - the framework should already take care of it.

So, I think this is a bug, but I'm really not sure which component is the bug.

+3
javascript angularjs firefox protractor


source to share


No one has answered this question yet

See similar questions:

2
Can I call functions in the module added by addMockModule? (protractor)

or similar:

4
Protractor - MouseMove is not supported for Firefox
3
Protractor: .click (). Then () .. failure in Firefox
2
Transcavator, Firefox, Windows Authentication, LastPass
2
Running protractor in firefox
2
Can I call functions in the module added by addMockModule? (protractor)
1
Protractor - Correct Handling of Errors ...
1
Multiple firefox profiles in protractor
1
Firefox on Protractor start but not working
1
Transportation starts from the screen
0
Angle testing with $ httpBackend - Service not being called



All Articles
Loading...
X
Show
Funny
Dev
Pics