Uncaught TypeError: Cannot read env property from undefined

I used jasmine 1.2.0 and it worked great. Now I use the same code, all the same as it was, the only difference is that I switched to jasmine 2.0.1 and now it doesn’t work ... all tests fail, and the error I get is this is: "Uncaught TypeError: Unable to read the env property from undefined".

Here is the SpecRunner.html file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Jasmine Spec Runner</title> <link rel="stylesheet" href="../app/bower_components/bootstrap/dist/css/bootstrap.css"/> <link rel="stylesheet" href="../app/bower_components/font-awsome/css/font-awesome.css"/> <link rel="stylesheet" href="../app/bower_components/datetimepicker/jquery.datetimepicker.css"/> <link rel="stylesheet" href="../app/css/style.css"/> <link rel="stylesheet" href="../app/bower_components/bootstrap-multiselect/dist/css/bootstrap-multiselect.css"/> <link rel="stylesheet" href="../app/bower_components/bootstrap-select/dist/css/bootstrap-select.css"/> <script type="text/javascript" src="../app/bower_components/jquery/dist/jquery.js"></script> <script type="text/javascript" src="../app/bower_components/underscore/underscore.js"></script> <script type="text/javascript" src="../app/bower_components/backbone/backbone.js"></script> <script type="text/javascript" src="../app/bower_components/bootstrap/dist/js/bootstrap.js"></script> <script type="text/javascript" src="../app/bower_components/moment/moment.js"></script> <script type="text/javascript" src="../app/bower_components/handlebars/handlebars.js"></script> <script type="text/javascript" src="../app/bower_components/datetimepicker/jquery.datetimepicker.js"></script> <script type="text/javascript" src="../app/bower_components/backbone-tastypie/backbone_tastypie/static/js/backbone-tastypie.js"></script> <script type="text/javascript" src="../app/bower_components/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script> <script type="text/javascript" src="../app/bower_components/bootstrap-select/dist/js/bootstrap-select.js"></script> <script type="text/javascript" src="../app/bower_components/backbone.localstorage/backbone.localStorage.js"></script> <link rel="shortcut icon" type="image/png" href="jasmine-2.0.1/jasmine_favicon.png"> <link rel="stylesheet" type="text/css" href="jasmine-2.0.1/jasmine.css"> <script type="text/javascript" src="jasmine-2.0.1/jasmine.js"></script> <script type="text/javascript" src="jasmine-2.0.1/jasmine-html.js"></script> <script type="text/javascript" src="jasmine-2.0.1/boot.js"></script> <script type="text/javascript" src="sinon.js"></script> . . . <!-- include spec files here... --> . . . <script type="text/javascript"> (function () { var jasmineEnv = jasmine.getEnv(); jasmineEnv.updateInterval = 1000; var htmlReporter = new jasmine.HtmlReporter(); var oldResult = htmlReporter.reportRunnerResults; jasmineEnv.addReporter(htmlReporter); /* this is just for our automated tests */ window.jasmine_phantom_reporter = new jasmine.ConsoleReporter; jasmineEnv.addReporter(jasmine_phantom_reporter); /* */ jasmineEnv.specFilter = function (spec) { return htmlReporter.specFilter(spec); }; var currentWindowOnload = window.onload; window.onload = function() { if (currentWindowOnload) { currentWindowOnload(); } execJasmine(); }; function execJasmine() { jasmineEnv.execute(); } })(); </script> </head> <body> </body> </html> 

Can someone tell me what is wrong ??? Tnxs :)

+5
source share
2 answers

I would make sure that the sinon.js you included will support jasmine 2.0, as there have been significant changes in how jasmine works with release 2.0. Also, check out the upgrade guide to help you convert existing specifications for working with 2.0.

In another note, starting from version 2.0, the boot.js file should do all the work available in your built-in script block, so it is no longer needed.

+1
source

Version 2 of jasmine seems to use the boot.js file to load settings and launch jasmine. You also have this setting specified in your inline script. Try removing the built-in script and allowing jasmine to load through the included boot.js , which you already have in the script.

0
source

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


All Articles