How to mock uuid with Jest

I figure I might as well add my solution here, for posterity. None of the above was exactly what I needed:

jest.mock('uuid', () => ({ v4: () => '123456789' }));

By the way, using a variable instead of '123456789' breaks it.

This should be mocked where we have the imports and it does not require you to explicitely import uuid in your spec file.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)