DEV Community

Visakh Vijayan
Visakh Vijayan

Posted on

SinonJs - to make the stubvalue random

 sinonSandbox .stub(LobService, 'createPostcard') .callsFake(() => { const postcard = new Postcard({ id: `psc_${faker.random.alphaNumeric(16)}` }); return Promise.resolve(postcard); }); 
Enter fullscreen mode Exit fullscreen mode

Everytime the function createPostcard is called, which is mocked btw, the function is called a new postcard is made.

Top comments (0)