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

feat(addMockModule): add third parameter to pass context #787

Closed
wants to merge 2 commits into from

Conversation

bmenant
Copy link
Contributor

@bmenant bmenant commented May 7, 2014

Allow Protractor’s 'addMockModule' method to pass context to its mocks,
providing an argument to the script which overrides a module.
Rely on the WebDriver’s 'executeScript' method.

Closes #695

Allow Protractor’s 'addMockModule' method to pass context to its mocks,
providing an argument to the script which overrides a module.
Rely on the WebDriver’s 'executeScript' method.

Closes angular#695
@juliemr
Copy link
Member

juliemr commented May 7, 2014

Automated CLA checker says: please sign CLA at http://code.google.com/legal/individual-cla-v1.0.html Please make sure that the email associated with your PR is the same as the email you use to sign.

@bmenant bmenant added cla: no and removed cla: yes labels May 7, 2014
@bmenant
Copy link
Contributor Author

bmenant commented May 7, 2014

Signed! Thank you.

@juliemr
Copy link
Member

juliemr commented May 7, 2014

CLA signature found, thank you!

@@ -837,10 +839,13 @@ Protractor.prototype.isElementPresent = function(locatorOrElement, varArgs) {
*
* @param {!string} name The name of the module to load or override.
* @param {!string|Function} script The JavaScript to load the module.
* @param {*=} argument The argument provided to the script as
* `arguments[0]`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be neat if this supported full var_args so you could pass more than one argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we could use this.moduleArgs_.push(Array.prototype.slice.call(arguments, 2)); there, and something like this.driver.executeScript.apply(null, [this.moduleScripts_[i]].concat(this.moduleArgs_[i])); below. I will test and commit it ASAP.

Allow Protractor’s 'addMockModule' method to pass context to its mocks,
providing arguments to the script which overrides a module.
Support any arguments provided in addition to the module’s name and
script. Those arguments may be referenced from the script via the
`arguments` object.
Rely on the WebDriver’s 'executeScript' method.

Closes angular#695
@juliemr juliemr self-assigned this May 20, 2014
@juliemr
Copy link
Member

juliemr commented May 20, 2014

Thanks for the updates! Merged as b7afa87

@juliemr juliemr closed this May 20, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to easily pass context to addMockModule
2 participants