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

I recently read about solving these protractor problems:

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


source to share





All Articles