79577667

Date: 2025-04-16 16:30:49
Score: 1.5
Natty:
Report link

While some of the information here is helpful, I'd like to address the root of the asker's specific question.

It fails with

TypeError: _dayjs.default.extend is not a function

Unfortunately similar questions on here didn't help me. How could I mock both default dayjs but also extend?

The default export of dayjs is a function with properties attached. Your mock needs to follow the same pattern. The following pseudo-code is written to be library agnostic:

const dayjsMock = () => ({
  add: () => {...}
});

dayjsMock.extend = () => {};

You'll plug this dayjsMock object into your specific mocking library's function.

Reasons:
  • Blacklisted phrase (1): help me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: user13860176