marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
828 stars 57 forks source link

Problem mocking interface that has 'name' property. #61

Open ayartsev7 opened 3 years ago

ayartsev7 commented 3 years ago

Hi, I use jest-mock-extended 1.0.13. Can not setup property 'name' of the mock. The following test

interface A {
  name: string;
}

interface B {
  a: A;
}

test('', () => {
  const bMock = mockDeep<B>();
  bMock.a.name = '';
});

ends up with

TypeError: Cannot assign to read only property 'name' of function 'function mockConstructor() {
    return fn.apply(this, arguments);
}'