działa dobrze z karma-jaśminem ..... ale nie działa z karma-mokka ... y ??
module.exports = function(config){
config.set({
basePath : "../app",
preprocessors: {
"**/*.html":"ng-html2js"
},
ngHtml2JsPreprocessor: {
prependPrefix: "/"
},
files : [
"node_modules/jquery/**/*.js",
"lib/angular/angular.js",
"lib/angular/angular-*.js",
"../test/lib/angular-mocks.js",
"../test/lib/sinon-1.15.0.js",
"../test/lib/chai.js",
"js/**/*.js",
"../test/unit/**/*.js",
"**/*.html"
],
autoWatch : true,
frameworks: ["mocha","requirejs","chai"],
browsers : ["Chrome"],
plugins : [
"karma-chrome-launcher",
"karma-mocha",
"karma-ng-html2js-preprocessor",
"karma-requirejs",
"karma-chai"
],
junitReporter : {
outputFile: "test_out/unit.xml",
suite: "unit"
}
});
};
MÓJ PRZYKŁADOWY KOD :::
"use strict";
describe("calendarHelper", function() {
beforeEach(module("eventsApp"));
it("should return January when given a zero", inject(function(calendarHelper) {
expect(calendarHelper.getMonthName(0)).toBe("January");
}))
});
Odpowiedzi:
0 dla odpowiedzi № 1Podobną sytuację spotkałem właśnie z Jasmine. Chciałbym przedstawić moje rozwiązanie.
Spróbuj tego, co jest napisane w komunikacie o błędzie. Link do strony internetowej: http://requirejs.org/docs/errors.html#notloaded
Użyj tego w swoim pliku specyfikacji:
//If this code is not in a define call,
//DO NOT use require("foo"), but use the async
//callback version:
require(["foo"], function (foo) {
//foo is now loaded.
});
Moja sprawa napisana dla Jasmine i Sinon w Coffeescript wygląda następująco:
sinon = require(["sinon", "jasmine-sinon"]) (foo)->
Teraz mogę używać sinon jako obiektu w teście jednostkowym, a także postępować zgodnie z dokumentacją sinon, a także jasmin-sinon.