我正在寻找对 firebase 数据库的 spyOn 调用。我有一个包装 firebase 调用的 FireFunc 文件。但是,当我使用 spyOn 检查方法时,它会返回常规结果。这里发生了什么?
var FireFunc = require("../js/services-fb-functions.js");
describe('Firebase Testing Suite', function() {
var firebase;
var testPath;
var testResult = {};
beforeAll(function() {
var firebaseFunctions = ['check']
firebase = jasmine.createSpyObj('firebase', firebaseFunctions)
firebase.check.and.callFake(function() {
return 2
});
});
describe('check', function() {
it('is working?', function() {
var x = FireFunc.zset()
expect(x).toBe(3); // THIS IS RETURNING 1... which means the spyOn doesn't work for me !
});
});
这是我的代码(js/services-fb-functions.js)
var firebase = {};
firebase.check = function() {
return 1;
}
module.exports = {
zset: function() {
return firebase.check();
}
}