powOfTwo.js代码exports.judge = function (a) {
if(a == 2) { return true;
} if(a % 2) { return false;
}else {
a = a / 2; return judge(a);
}
}测试代码:var powerOfTwo = require('../powerOfTwo.js');
describe('basic test', function(){
it('test sample', function() {
expect(powerOfTwo.judge(16)).toBe(true);
expect(powerOfTwo.judge(12)).toBe(false);
expect(powerOfTwo.judge(1024)).toBe(true);
})
})报错:$ jasmine-node powerOfTwo-spec.jsFFailures:
1) basic test test sample Message: ReferenceError: judge is not defined Stacktrace:
ReferenceError: judge is not defined at Object.exports.judge (D:\vanilla-javascript\powerOfTwo.js:9:16)
at .<anonymous> (D:\vanilla-javascript\spec\powerOfTwo-spec.js:5:27)Finished in 0.065 seconds1 test, 1 assertion, 1 failure,
0 skipped
添加回答
举报
0/150
提交
取消