#How to assert object with a field of a given type?

3 messages · Page 1 of 1 (latest)

pastel sail
#

Hi, I'm writing an integration test that needs to assert an object response, where the ID field can be of type string:

const json = await res.json();
assertObjectMatch(json, {
    data: {
        object: "VerificationRequest",
        id: expect.any(String)
    },
});

The expect.any(String) line doesn't work because that syntax is from Jest: https://jestjs.io/docs/expect#expectanyconstructor

Is there any way to do this in Deno?

#

I'm trying to assert that the data object has an id field of type String , while also asserting the remaining fields with assertObjectMatch

#

I couldn't find anything similar to Jest's expect.any(String) in the Deno testing docs