I have a jest spyOn with the uuid which was working in the version 3.4.0 after upgrading it to 8.3.2 the test breaks with the error Cannot spyOn on a primitive value; undefined given
import uuid from 'uuid';
jest.spyOn(uuid, 'v4');
I have a jest spyOn with the uuid which was working in the version 3.4.0 after upgrading it to 8.3.2 the test breaks with the error Cannot spyOn on a primitive value; undefined given
import uuid from 'uuid';
jest.spyOn(uuid, 'v4');
The best way to mock uuid lib version 8.x is using Mocking Partials:
jest.mock( 'uuid', () => ({
v4: jest.fn(() => '1234567890' )
}));
You need to change the way you import uuid
import { v4 as uuidv4 ) from uuid;