Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot read property 'env' of undefined

I used jasmine 1.2.0 and it worked perfectly. Now I am using the same code everything the same as it was, the only differance is that I moved to jasmine 2.0.1 and now its not working... all the tests fails, and the error I get is : "Uncaught TypeError: Cannot read property 'env' of 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>
like image 309
Vladi Isakov Avatar asked Nov 09 '22 23:11

Vladi Isakov


1 Answers

I would make sure that the sinon.js that you've included will support jasmine 2.0, as there were significant changes made to how jasmine works with the 2.0 release. Additionally, check out the upgrade guide to help with converting your existing specs to work with 2.0.

On another note, as of 2.0, the boot.js file should do all of the work you have in your inline script block so that should no longer be necessary.

like image 143
Gregg Avatar answered Nov 15 '22 12:11

Gregg