ile çalışmaya çalışmıyor Verileri almak için bir 3. lib kullanmakta olan bir JS'yi test etmek istiyorum, bu yüzden bu uygulamada mock kullanıyorum. Doğrudan testte dediğimde çalışıyor. Ancak, kaynak kodunda kullanıldığında çalışmaz.jest mock application required ('')
İşte gerektirir ait Siparişiniz yanlış kod
//Source implementation
var reference = require('./reference');
module.exports = {
getResult: function() {
return reference.result();
}
};
//Test code
jest.dontMock('./foo');
jest.dontMock('console');
describe('descirbe', function() {
var foo = require('./foo');
it('should ', function() {
var reference = require('./reference');
reference.result.mockImplementation(function (a, b, c) {
return '123'
});
console.log(foo.getResult()); // undefined
console.log(reference.result()); // 123
});
});