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

Commit 56beb24

Browse files
committed
feat(protractor): add browser.getRegisteredMockModules()
Now `browser.getRegisteredMockModules()` returns a list of the functions or strings that have been registered as mock modules. For troubleshooting. Closes #1434.
1 parent 0b93003 commit 56beb24

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/protractor.js

+11
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,17 @@ Protractor.prototype.removeMockModule = function(name) {
379379
}
380380
};
381381

382+
/**
383+
* Get a list of the current mock modules.
384+
*
385+
* @return {Array.<!string|Function>}
386+
*/
387+
Protractor.prototype.getRegisteredMockModules = function() {
388+
return this.mockModules_.map(function(module) {
389+
return module.script;
390+
});
391+
};
392+
382393
/**
383394
* Add the base mock modules used for all Protractor tests.
384395
*

spec/basic/mockmodule_spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ describe('mock modules', function() {
8585
expect(element(by.css('[app-version]')).getText()).toEqual('42beta');
8686
});
8787

88+
it('should retrieve a list of current mock modules', function() {
89+
browser.addMockModule('moduleA', mockModuleA);
90+
browser.addMockModule('moduleC', mockModuleC, '2', 'B');
91+
92+
// Should have 3 mock modules, A, C, and the base.
93+
expect(browser.getRegisteredMockModules().length).toBe(3);
94+
expect(browser.getRegisteredMockModules()[1]).toEqual(mockModuleA);
95+
expect(browser.getRegisteredMockModules()[2]).toEqual(mockModuleC);
96+
});
97+
8898
it('should load mock modules after refresh', function() {
8999
browser.addMockModule('moduleA', mockModuleA);
90100

0 commit comments

Comments
 (0)