golevelup / nestjs

A collection of badass modules and utilities to help you level up your NestJS applications 🚀
MIT License
2.26k stars 259 forks source link

jest-fn: setting properties on nested values, doens't override the cached values #765

Closed rbnayax closed 1 month ago

rbnayax commented 1 month ago

The following test fails:

    it('nested properties mocks should be able to set properties and override cache', () => {
      const mock = createMock<any>();
      const autoMockedFn = mock.nested.f;
      expect(typeof autoMockedFn).toEqual('function');
      const myFn = () => 5;
      mock.nested.f = myFn;
      expect(mock.nested.f === myFn).toBeTruthy(); // Fails
    });
WonderPanda commented 1 month ago

Fix released in @golevelup/ts-jest@0.5.4