Is it possible to use expect.stringContaining()
inside a Jest .toHaveBeenCalledWith()
block?
I am currently using:
expect(createChatRoomMock).toHaveBeenCalledWith({
creatorId: expect.stringContaining("user_"),
chatRoomUuid: expect.stringContaining("chatRoom_"),
});
But this fails with:
- Expected
+ Received
Object {
- "chatRoomUuid": StringContaining "chatRoom_",
- "creatorId": StringContaining "user_",
+ "chatRoomUuid": "chatRoom_sZ9nj4hC46e4bGz4PjYzpC",
+ "creatorId": "user_nCQsasvYirUwwoEr3j8HsC",
},
This is odd, as you can see from the error, the recieved strings match what's expected
I've also tried:
expect(createChatRoomMock).toHaveBeenCalledWith({
creatorId: expect.stringMatching(/user_.*/),
chatRoomUuid: expect.stringMatching(/chatRoom_.*/),
});
With the same results as shown above.
How can I use expect.stringContaining()
inside a Jest .toHaveBeenCalledWith()
block?
Aucun commentaire:
Enregistrer un commentaire