Hello everyone. I am new to jquery and javascript. I wrote the code and want to test it. But I got stuck at some point and need help from experts.
Here is my jquery define class in myfile.js
$.fn.MyClass = function(arg1 ,arg2, arg3) { function MyFirstFunc (arg1, arg3) {
And in my index.html file I need to call my jquery class on a DOM object like this
$("#div1").MyClass(agr1_val, arg2_val, arg3_val);
Now I want to do unit testing of these functions and save the test cases in a separate file. I chose Qunit. I wrote the following test
test('MyFirstFunction function test', function() { equal(MyFirstFunc (4, 5),"9" ,"function working correctly"); });
Also in my index_test.html file I gave the path to myfile.js file, but Qunit still gives me an error
Died on test # 1 in file: ///var/www/test.js: 2: 1: MyFirstFunc not defined
Can someone kindly guide me where I am doing wrong, and how to test functions by storing test cases in a separate file Or any other better way to do this.
thanks
source share