How to assert for object exactly, except for one key by type #5643
Unanswered
jamischarles
asked this question in
Q&A
Replies: 1 comment
-
Yes, it exists: const expectedEmitPayload = {
"name": "joe",
"type":"counter",
"time": expect.any(Number), // always variable
}
expect(mockEmitCb).toHaveBeenLastCalledWith(expectedEmitPayload); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi folks 👋 . LOVE vitest.
I have a very common situation where 90% of the values in my object are fixed, and 1 is variable (like a
time
value).What I've done in the past (but don't love):
matchObject()
don't love this because it doesn't check for key completeness (you can add/remove some)What I'm looking for
Personally I'd LOVE something like this:
Does anything like that exist? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions