Just starting with Jasmine and following the instructions on the Jasmine website for async testing I notice the beforeEach function is never called.
Any idea why not? I don't find any hints relevant anywhere on the web. Thanks.
Code
The code is really simple:
describe("Testing test.php", function()
{
it ("Gets me a coke", function()
{
var asyncResult = null;
// query function with callback
var queryFcn = function(callback)
{
console.log("queryFcn");
$.get("be_com/test.php?coke")
.success(function(data)
{
asyncResult = data.response;
callback(); // notify jasmine
})
.error(function() { callback(); });
};
// Call ajax
beforeEach(function(done) {
console.log('beforeEach');
queryFcn(done); });
// Evaluate response
expect(asyncResult).toBe("a can of coke");
});
});
The HTML is equally simple:
<html>
<head>
<link rel="shortcut icon" type="image/png" href="../fe_com/js/lib/jasmine-standalone-2.3.4/lib/jasmine-2.3.4/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="../fe_com/js/lib/jasmine-standalone-2.3.4/lib/jasmine-2.3.4/jasmine.css">
<script type="text/javascript" src="../fe_com/js/lib/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="../fe_com/js/lib/jasmine-standalone-2.3.4/lib/jasmine-2.3.4/jasmine.js"></script>
<script type="text/javascript" src="../fe_com/js/lib/jasmine-standalone-2.3.4/lib/jasmine-2.3.4/jasmine-html.js"></script>
<script type="text/javascript" src="../fe_com/js/lib/jasmine-standalone-2.3.4/lib/jasmine-2.3.4/boot.js"></script>
<!-- FILES -->
<script type="text/javascript" src="testSpec.js"></script>
</head>
<body>
<h2>Unit Tests</h2>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire