awslabs/aws-jwt-verify

How to mock CognitoJwtVerifier.create().verify - Jest - Unit Testing

sandun86 opened this issue · 2 comments

How can we mock the following code using Jest

    const verifier = CognitoJwtVerifier.create({
      userPoolId: 'userPoolId',
      tokenUse: 'access',
      clientId: 'clientId',
    });

    const payload = await verifier.verify(awsCognitoToken);

Hi @sandun86 what exactly do you want to do, what problem do you encounter?

Here's a simple mock:

const mock = { create: () => ({ verify: async (jwt) => ({ claim: "claim value" }) }) };

Closing for now, let us you if you still have questions