假设我要测试此功能:
function thisFunctionWillBeTested(){
const activeXObejct = new ActiveXObject('Something.App');
//And do more after ActiveXObject is created.
}
现在我想测试该功能,但是我不知道如何模拟对象的创建:
test('test of my function', () => {
// Arrange
//I need to Mock >ActiveXobject here
//Act
const returnValue = thisFunctionWillBeTested();
//Assert
expect(returnValue).toBe(10);
});