JsTestDriver Test Aborts After Upgrading to 1.3.5

After upgrading to version 1.3.5 from 1.3.4, a reference to the undefined variable causes the tests to fail. Any suggestions for disabling this behavior? I think this is due to js hard mode, that it allows it by default, but cannot find a way to disable it.

Part of the JsTestDriver.conf file:

load: - program.js - dialog.js 

program.js:

 Program = {}; 

dialog.js:

 Program.Dialog = {}; 

Error message: ReferenceError: The program is not defined.

+4
source share
2 answers

Now you can capture various browsers (or various browser settings, such as a console opened in IE or in strict mode), which now throw different exceptions, or perhaps your code base has changed since then.

JsTestDriver did not change the behavior for certain / undefined processing variables for 1.3.5, since it just catches browser exceptions.

Anyway, jsTestDriver does not call fail test, but calls validation when specifying undefined.

For example, for this piece of code in the code base (asuming undef is undefined var):

 if(undef) alert("foo"); 

JsTestdriver output when running tests from the command line:

 Total 2 tests (Passed: 1; Fails: 0; Errors: 1) (1,00 ms) Chrome 23.0.1271.64 Windows: Run 2 tests (Passed: 1; Fails: 0; Errors 1) (1,00 ms) PersonTest.testWhoAreYou error (0,00 ms): ReferenceError: undef is not defined 

As you can see, the test suite had 1 error, but 0 failed .

EDIT . For your case, it would be possible for jsTestDriver to add a closure around your namespace definition. try it

Instead:

 var Program = {}; 

Using:

 window.Program = {}; 

for Program.Dialog you do not need to change anything

Please try to find out no reason.

0
source

Best practice is to define your own undefined ( jstestdriver.util.undefine; ) or to use void 0 .

-1
source

Source: https://habr.com/ru/post/1442991/


All Articles