onclick() in html not finding f() in external .js

77 views
Skip to first unread message

J Spence

unread,
May 28, 2019, 5:43:01 PM5/28/19
to Jasmine
Hello,

I'm running a test and I'm getting the following error:

"TypeError: jlsTest.Widget.Submit is not a function"


describe("Testing: Submit Button...", function() {
   beforeEach(function() {
      setFixtures('<form id="my-form"></form>');
      appendLoadFixtures('jlsTest-One.html');         // Contains the onclick
      var spyEvent;
   });
   it ("should invoke the lastNameButtonId click event.", function() {
      spyEvent = spyOnEvent('#lastNameButtonId', 'click');
      $('#lastNameButtonId').click();
      expect('click').toHaveBeenTriggeredOn('#lastNameButtonId');
   });
});


<button id="lastNameButtonId" type="button" class="btn btn-primary" onclick="jlsTest.Widget.Submit()">Submit</button>




For some reason the function isn't being found. I believe this is true because I copied the function from 
the external javascript file and inserted in the html file between <script> tags and it worked.

My SpecRunner includes the js file along with other js files that I have run other successful tests. 
For example:

it("Symbol should be AOUE", function() {
      expect(jlsTestPeopleInput.symbol).toBe('AOUE');
});


Does anyone have any suggestions as to why my function isn't being found?
Thank you,
JS.

Reply all
Reply to author
Forward
0 new messages