我正在尝试使用jasmine来测试代码片段,但由于Jasmine的原因,它总是通过它的方法被异步调用。这是我的测试代码
function outer() {
it("| --- BEFORE OUTER ---|", function() {
expect("yes").toEqual("yes");
});
it("outer() is in scope", function() {
expect(typeof outer).toEqual('function');
});
it("inner() is in scope", function() {
expect(typeof inner).toEqual('function');
});
it("a is in scope", function() {
console.log('Why this is running after');
expect(typeof a).toEqual('number');
});
it("b is in scope", function() {
expect(typeof b).toEqual('number');
});
it("c is in scope", function() {
expect(typeof c).toEqual('number');
});
console.log("This is running first");
var a = 1;
function inner() {}
var b = 2;
if (a == 1) {
var c = 3;
}
}
outer();
如何解决这个问题?我想在运行声明语句(如var a = 1;
)之前立即运行它的回调方法