Reputation: 289
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>
Upvotes: 5
Views: 4252
Reputation: 464
Version 2 of jasmine appears to use the boot.js
file to load the settings and initiate jasmine. You also have this setup specified in your inline script. Try removing the inline script and allow jasmine to load via the included boot.js
you already have in your script includes.
Upvotes: 0
Reputation: 2638
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.
Upvotes: 1