我正在努力让jasmine和它的ConsoleReporter一起在使用require.js的主干应用程序中工作。我见过Check Backbone/requireJs project with Jasmine,但它对库进行了硬编码(这是我希望避免的)。
在我的主干应用程序中,我创建了测试函数(我更喜欢将其保留在那里以测试模型之间的交互):
test = function () {
require(['js/test/run'], function () {});
}和run.js (我知道console.log“应该”没问题,但是不要和失败的测试有任何关系):
define(["jasmine", "jasmineConsoleReporter"],
function (jasmine, ConsoleReporter) {
describe('hello', function () {
it('should be true', function () {
console.log('should');
expect(true).toEqual(true);
});
});
jasmine.getEnv().addReporter(new ConsoleReporter(console.log));
jasmine.getEnv().execute();
//return tests;
}
);jasmine和jasmineConsoleReporter的填充是:
jasmine: {
exports: "jasmine"
},
jasmineConsoleReporter: {
deps: ['jasmine'],
exports: "getJasmineRequireObj"
}可以在https://github.com/pivotal/jasmine/blob/master/src/console/console.js上找到jasmineConsoleReporter的源代码
我猜控制台报告器没有被正确构造,因为我在控制台中得到了“应该”,而没有得到其他东西。
发布于 2014-01-30 07:35:20
https://stackoverflow.com/questions/17078201
复制相似问题