Ich habe QUnit-Test erstellt, um sicherzustellen, dass mein JSON über AJAX korrekt geladen und analysiert wird, alles funktioniert im Browser einwandfrei, aber wenn ich es über Grunt starte, bekomme ich den Fehler:Grunt hat keinen Qunn-Test mit Ajax-Aufrufen ausgeführt
Running "qunit:files" (qunit) task
Testing test/index.html ...
>> PhantomJS timed out, possibly due to:
>> - QUnit is not loaded correctly.
>> - A missing QUnit start() call.
>> - Or, a misconfiguration of this task.
Warning: 1 tests completed with 1 failed, 0 skipped, and 0 todo.
0 assertions (in 0ms), passed: 0, failed: 0 Use --force to continue.
Aborted due to warnings.
hier mein Test:
QUnit.test("TSO json loader test", function (assert) {
assert.expect(2);
var done = assert.async();
var done1 = assert.async();
var tsoGrid = new TsoGrid(".testCont");
tsoGrid.loadJsonDataArray("/test/ajax.json", {}, function (jsonResult) {
assert.ok(jsonResult[0][0] === "Lorem ipsum", 'ajaxImportFromJson');
done();
var jsonRes = jsonResult.importFromJsonArray();
var resArray = [["Lorem ipsum"],
["Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante."],
[
[["Lorem ipsum dolor sit amet, consectetuer adipiscing elit."],
["Aliquam tincidunt mauris eu risus.", "Aliquam tincidunt mauris eu risus.1", "Aliquam tincidunt mauris eu risus.2"],
["Vestibulum auctor dapibus neque."]]
]];
assert.ok(jsonRes.isEquals(resArray), 'AjaxImportFromJsonArray');
done1();
});
});
ich versuche, darüber zu google, aber nach QUnit bewegt (Async) und stoppt start() und stop() alle Antworten veraltet sind :(
Ich finde Problem, hier Lösung:
Ich URL für Abfrage von der Wurzel meiner Website setzen, wenn ich es entfernen, auf Datei selbst einstellen, jetzt es Tests von grunt!
Also brauchen wir String dies ändern:
tsoGrid.loadJsonDataArray("ajax.json", {}, function (jsonResult) {
/test/
vom Weg entfernen.
Warum haben Sie 'done' AND' done1'? Du solltest beides nicht brauchen. – jakerella
@jakerella Becouse, wenn ich dies tue, bekomme ich Fehler im Browser:
Too many calls to the 'assert.async' [email protected] 28 ms Source: \t @http://tso/test/test.js:137:9
–Was? Nein ... du brauchst nur einen ... den letzten. – jakerella