Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit b783dd8

Browse files
donataswixjuliemr
authored andcommitted
fix(browser): remove subsequent duplicate module
browser.removeMockModule() misses next duplicate module because of iteration over an array it's modifying.
1 parent e3d4ad1 commit b783dd8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/protractor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ Protractor.prototype.clearMockModules = function() {
386386
Protractor.prototype.removeMockModule = function(name) {
387387
for (var i = 0; i < this.mockModules_.length; ++i) {
388388
if (this.mockModules_[i].name == name) {
389-
this.mockModules_.splice(i, 1);
389+
this.mockModules_.splice(i--, 1);
390390
}
391391
}
392392
};

spec/basic/mockmodule_spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ describe('mock modules', function() {
6868
expect(element(by.css('[app-version]')).getText()).toEqual('2');
6969
});
7070

71+
it('should remove duplicate mock modules', function () {
72+
browser.addMockModule('moduleA', mockModuleA);
73+
browser.addMockModule('moduleA', mockModuleA);
74+
browser.removeMockModule('moduleA');
75+
76+
browser.get('index.html');
77+
78+
expect(element(by.css('[app-version]')).getText()).toEqual('0.1');
79+
});
80+
7181
it('should be a noop to remove a module which does not exist', function() {
7282
browser.addMockModule('moduleA', mockModuleA);
7383
browser.removeMockModule('moduleB');

0 commit comments

Comments
 (0)