Resharper中的Jasmine和Requirejs 7 [英] Jasmine and Requirejs in Resharper 7
问题描述
我正在尝试使用visual studio 2012中的jasmine和Resharper 7运行一些JavaScript代码。我在requirejs的帮助下遵循AMD模式。但是,我还没有设法让我的测试运行在Resharper测试运行器中。
I'm trying to run some JavaScript code using jasmine and Resharper 7 within visual studio 2012. I follow the AMD pattern with the aid of requirejs. However, i haven't managed to make my test run in the Resharper test runner.
有没有人设法做类似的事情?
Has anyone managed to do anything similar to that?
推荐答案
使用命名的requireJS模块
Use a named requireJS Module
define("my/sut", function () {
var MySut = function () {
return {
answer: 42
};
};
return MySut;
});
并使用Jasmine的asyncronus支持初始化SUT。不要忘记引用!
And initialize the SUT with the asyncronus support of Jasmine. Don't forgot the references!
/// <reference path="~/Scripts/require.js"/>
/// <reference path="../code/sut.js" />
describe("requireJS with Jasmine and Resharper", function () {
it("should be executed", function () {
// init SUT async
var sut;
runs(function () {
require(['my/sut'], function (MyModel) {
sut = new MyModel();
});
});
waitsFor(function () {
return sut;
}, "The Value should be incremented", 100);
// run the test
runs(function () {
expect(sut.answer).toBe(42);
});
});
});
我希望这适用于更多模块。在我的情况下,它使用waitsFor'0'ms。
I hope this works with more modules. In my case it worked with waitsFor '0' ms.
这篇关于Resharper中的Jasmine和Requirejs 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!