javascript - Accessing Qunit Module setup variables -


hi guys, i'm testing javascript code qunit testing framework. not able access qunit.module setup variables in qunit.test function.

qunit.module( "module a:build notes",{     setup: function () {         this.inputsticky = $("input[name=stickyinput]");     } }); qunit.test("test case 1",function (assert) {     assert.expect(1);                 orangeclick(); //changing color                                                         assert.equal( this.inputsticky.css('background-color'),'rgb(255, 165, 0)', "orange function passed !" ); }); 

result: this.inputsticky undefined

per comments, if want hold onto html element can create variable outside of module entirely. using this isn't going work (that know of):

(function() {   // put things in iife prevent data leakage    let inputelement;  // define variable @ higher scope    qunit.module( "module a:build notes",{     setup: function () {       // can set variable's value use in later tests       inputelement = $("input[name=stickyinput]");     }   });   qunit.test("test case 1",function (assert) {     assert.expect(1);                 orangeclick(); //changing color                                                         assert.equal( inputelement.css('background-color'),'rgb(255, 165, 0)', "orange function passed !" );   });  })(); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -