I am facing an issue with an Angular directive that includes a <form>
element with ng-submit bound to a function in the directive controller. While setting up and running the code and unit tests individually works fine.
The problem arises when running all of the unit tests together, resulting in unexpected behavior like
PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR
Some of your tests did a full page reload!
allMessages PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR
Some of your tests did a full page reload!
PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR
Some of your tests did a full page reload!
Below is the specific unit test causing the issue:
it('Verify submit button is clicked', function () {
var btnSubmit = form.querySelector('#submit');
btnSubmit.click();
timeout.flush();
expect(scope.blah).to.equal(blah);}
If I comment out the line btnSubmit.click()
, everything works as expected.
Here is a snippet of the HTML code:
<paper-dialog modal class="pa-paper-dialog" id="blah" role="alertdialog">
<paper-button
dialog-dismiss
class="close-button"
ng-click="resetPA(event)">
</paper-button>
<form class="blah" is="iron-form" ng-submit="submitFunction(blah)" method="get" action="/" id="form">
<div class="pa-header">text</div>
<div class="input-fields-panel"></div>
<div class="buttons-panel">
<button type="submit" class="blah" id="submit">Admit</button>
<paper-button noink dialog-dismiss class="blah" ng-click="resetPA(event)">Cancel</paper-button>
</div>
</form>
</paper-dialog>
Any thoughts on why this might be happening?
Thank you!