-
I'm trying to check if an API-call sets a refresh_token cookie, but I can't seem to figure out how. The value of the cookie is a JWT so I can't check the actual value, I just want to check if it gets set. I have tried: .expectCookiesLike('refresh_token', 'string') ...which fails with: I have tried: .expectCookiesLike('refresh_token', String)` ...which fails with: After struggling for ages to figure out the correct syntax for .expectCookiesLike({'refresh_token': {
'type': 'string'
}}) ...which also fails with: Basically it seems that whatever i try to specify other than I'm fairly green when it comes to automated testing, which is what I'm trying to change, but I suspect I'm missing something painfully obvious and that I can't see the forest for the trees... A little help, please? :) (Using pactum 3.6.0 with NestJS 10.3.3 and Nx 18.0.4) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Ok, so I kept hammering away at this even though I'd given up while waiting and hoping for someone to come to my rescue here, but I found a solution with RegExp. So the solution to this specific case would be something like this: .expectCookiesLike('refresh_token', /[A-Za-z0-9\-_.]{128,}/) This should match any JWT with atleast 128 characters(*). The smallest I was able to generate on jwt.io was 84, but that was with no actual data. The ones in my API are currently 135ish but they'll get bigger before I'm done. Specifying an upper limit here is probably unnecessary, atleast for my use. |
Beta Was this translation helpful? Give feedback.
Ok, so I kept hammering away at this even though I'd given up while waiting and hoping for someone to come to my rescue here, but I found a solution with RegExp.
The docs do not mention that this is possible for
expectCookiesLike()
but it does describe it forexpectJsonLike()
so I figured "Like" and "Like", maybe they're handled the same way under the hood, so I gave it one more shot, and it worked. I'm posting here in case someone else googles for ages with little luck like I did, so hopefully they'll find this :)So the solution to this specific case would be something like this:
This should match any JWT with atleast 128 char…