Skip to content

Jest integration nested values #24102

Closed Answered by alexnsorensen
alexnsorensen asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, what I ended up having to do was this:

prismaMock.person.findUniqueOrThrow.mockReturnValue({
    posts: jest.fn().mockResolvedValue(posts),
    then: jest.fn().mockReturnValue(Promise.resolve(mockedPerson))(),
    catch: jest.fn().mockResolvedValue(null),
    finally: jest.fn().mockResolvedValue(mockedPerson)(),
    [Symbol.toStringTag]: 'PrismaPromise',
});

If I didn't add these then I would get a tonne of TS errors, so I Imagine it's to do with my TS settings probably being rather strict...

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@alexnsorensen
Comment options

Answer selected by alexnsorensen
@raphaelumoh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants