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

Commit

Permalink
feat(protractor): add browser.getRegisteredMockModules()
Browse files Browse the repository at this point in the history
Now `browser.getRegisteredMockModules()` returns a list of the functions
or strings that have been registered as mock modules. For troubleshooting.

Closes #1434.
  • Loading branch information
juliemr committed Jan 6, 2015
1 parent 0b93003 commit 56beb24
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,17 @@ Protractor.prototype.removeMockModule = function(name) {
}
};

/**
* Get a list of the current mock modules.
*
* @return {Array.<!string|Function>}
*/
Protractor.prototype.getRegisteredMockModules = function() {
return this.mockModules_.map(function(module) {
return module.script;
});
};

/**
* Add the base mock modules used for all Protractor tests.
*
Expand Down
10 changes: 10 additions & 0 deletions spec/basic/mockmodule_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ describe('mock modules', function() {
expect(element(by.css('[app-version]')).getText()).toEqual('42beta');
});

it('should retrieve a list of current mock modules', function() {
browser.addMockModule('moduleA', mockModuleA);
browser.addMockModule('moduleC', mockModuleC, '2', 'B');

// Should have 3 mock modules, A, C, and the base.
expect(browser.getRegisteredMockModules().length).toBe(3);
expect(browser.getRegisteredMockModules()[1]).toEqual(mockModuleA);
expect(browser.getRegisteredMockModules()[2]).toEqual(mockModuleC);
});

it('should load mock modules after refresh', function() {
browser.addMockModule('moduleA', mockModuleA);

Expand Down

0 comments on commit 56beb24

Please sign in to comment.