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)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series