qunit - JavaScript make custom object from another file for testing -


i'm writing qunit tests following html file:

var pinpointservice = {      doajax: function(doajax_params) {           //do stuff      }      //a bunch more variables , functions } 

the test i'm writing in seperate file:

qunit.test("test", function(assert) {     var array = [];     pinpointservice.doajax(array);     //assert stuff }); 

the error get:

pinpointservice not defined 

my main js file:

<!doctype html> <html> <head>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width">   <title>pinpoint test</title>   <link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.0.0.css">    <script src="http://code.jquery.com/jquery-latest.js"></script>     <script src="https://code.jquery.com/qunit/qunit-2.0.0.js"></script>   <script type="text/javascript" src="c:\path\to\jshamcrest.js"></script>   <script type="text/javascript" src="c:\path\to\core.js"></script>   <script type="text/javascript" src="c:\path\to\integration.js"></script>     <script type="text/javascript" src="c:\path\to\jsmockito-1.0.4.js"></script>   <script type="text/javascript" src=""></script>   <script src="c:\path\to\pinpoint.html"></script>   <script src="c:\path\to\pinpointtest.js"></script> </head> <body>   <div id="qunit"></div>   <div id="qunit-fixture"></div>  </body> </html> 

is there additional have besides including pinpoint.html in main js file? i'm new javascript, think missing fundamentals of how language works in contrast java i'm comfortable with.

make sure import file

qunit.test("test", function(assert) {     var array = [];     pinpointservice.doajax(array);     //assert stuff }); 

is located, after imported pinpointservice.

so in html file should like

...  <script src="c:\path\to\pinpointtest.js"></script> <script src="file_containing_the_code_above"></script> ... 

the html page read , included top bottom if have not included pinpointtest file yet, can not use inside it.


Comments