cancel
Showing results for 
Search instead for 
Did you mean: 

Identifying undefined variables in functions: JavaScript

Identifying undefined variables in functions: JavaScript

I would like to request feature which will show a syntax error in Editor workspace for undefined variables as like in Eclipse.

 

In below example, Currently no syntax error is displayed but it is having warning or error which is undefined variable.

 

For Ex:

function test()
{
     var testvar = "1";
     
     if(testvar == expectedvar)
    {
         Log.Error("balhblah")
    }

}

Currently, we will come to know about undefined variables only when we run the function and also TC is taking around 15 + mins to identify this undefined variable. [I know this time is because i'm having huge units]

 

If we have this feature then it would be good suppress the undefined error.

 

2 Comments
tristaanogre
Community Hero

That would be cool.  I'll upvote.

 

Could be tricky, though... scripting languages are by their nature not very strict in variable declarations.  Technically speaking, in JavaScript, I don't need to use var blahblah to declare a variable... I can just start using a variable and JavaScript will just carry on as normal.

 

I think DelphiScript is more strict as is VBScript... not sure about Python.  But JScript, C#Script, etc., in TestComplete are all based off a similar JavaScript engine so this might be a bit tough to implement.

shankar_r
Community Hero

@tristaanogre yes we can do scripting without declaring, However in below cases script fail due to undefined.

 

1) Variable not declared but it is used in function parameter like below, In this case testvar is undefined hence it will shoot a error.

 

 

function test()
{
       var param1 = "test";

       testcalfunction(param1,testvar);
}

2) Variable declared but typo [this basically developer mistake but if have this option we can caught ]

 

function test()
{
       var para1 = "test";
       var testvar = "test2";
       testcalfunction(param1,testvar);
}

 

 

Announcements
Welcome to the TestComplete Feature Requests board!

Here you can review submitted feature requests and vote up the ones you like! If you can't find the feature you want - go ahead and suggest your own idea. Ideas with the highest rating can be implemented in the product.

Check out the Create a Feature Request guide for more information.
New Here?
Join us and watch the welcome video:
Announcements