I’am using jasmine for testing JavaScript code.
The javascript code is made of module which are loaded using requireJs.
When I load json file using json requirejs-plugins which requires text! plugin I cannot see any output on the web browser.
The strange thing is also I don’t get any javascript error.
Here’s my code (1).
Any ideas?
P.S.:
Not sure but maybe the problem is about time latency.
If I get the file from the local (time latency = 6ms) it works.
If I get the file (with the same content of local) from a remote server (time latency = 170 ms) it display an empty page.
Any idea how can I fix this problem?
(1)
/*global define, window*/
(function () {
'use strict';
var specUrl = './';
define([
'jasmine',
'jasmineHtml',
'jasmineJquery',
'json!json_data', // if I comment this line is ok,
// otherwise I get empty page with no error
specUrl + 'models/user.spec'
], function (jasmine) {
var initialize = function () {
// some code
};
return {
initialize: initialize
};
});
}());
I did read the documentation about Asynchronous specs but it is not clear how can I fix the issue, yet. Any ideas?
I did post a very simple code: (1) which works, (2) which does not works because, maybe, getting json_data from the server requires about 250ms.
(1)
define([
'appJasmine',
// 'json!json_data',
], function (app) {
app.initialize(); // it display data on browser
});
(2)
define([
'appJasmine',
'json!json_data',
], function (app) {
app.initialize(); // it does not display data on browser
});
If you run execJasmine before all modules will be ready you will get empty page.
So you should post your code about execJasmine call.
For example, if you are running this code:
you will get an empty page.
If you run this one, it should work.