javascript - Cannot reference global function in nested describe function in Jasmine -
I am TDD for a JavaScript app with Jasmine. For some reason I can not reference the declared work in the source portion of the SpecRunner.html file if it is nested inside two functions.
Here is the code:
("DidiButton", function () {var didiButtonDiv = document.createElement ("div"); didiButtonDiv.id = "DidiButtonDiv"; ("It should throw an undefined alimentary air if it did not return a DOM", function () {try {var didi button = createDidiButton ();} catches (e) {hope (e.name) .toqual ("undefinedElementError" ("Link functions", function () {var didiButton = createDidiButton (didiButtonDiv); var link = "http: // www" ("link functions", "function ()" ("must be able to associate themselves with a DOM"); .google.com "; (" should be able to set a link ", function () {didiButton.setLink (link);}); ("it should be able to set the link" function () {hope (link) .toqual (didiButton.getLink ());});})}}; < / pre> This is an error I get:
Reference: not defined in the createDidiButton file: ///Users/.../spec/ DidiButtonSpec.js (line 20) If I remove the description ("link functions", function () {...}}; block, pass test I have a simple with nested functions Have tested whether I am going mad; I wrote the script below and called funcHi () . It has worked, like I thought it should be, and were able to find the message for each warning. function message () {return "hi"; } Function funcHi () {warning (message ()); Function Func1 () {Warning (Message () + 1); Function Func2 () {Warning (Message () + 2); Function (func3) {Warning (Message (+) 3); } Func3 (); } func2 (); } Func1 (); } Why is not jasmine able to find my function?
I found out: Jasmine SpecRunner.html Understand the context of the files contained in the file's source script Can not find, unless they are in any specific, or this (...) function. The internal description block works if I change it in the following: Description ("link functions", function () {var didiButton; var link = "http://www.google. com "(this should be able to" set a link ", function () {didiButton = createDidiButton (didiButtonDiv); didiButton.setLink (link);} (" it should be able to set it on the link "function () {Hope (link) .toqual (didiButton.getLink ());});});
Comments
Post a Comment