Skip to content

API e2e testing: How to check for a specific cookie in the response #316

Answered by NorseJedi
NorseJedi asked this question in Q&A
Discussion options

You must be logged in to vote

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 for expectJsonLike() 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:

.expectCookiesLike('refresh_token', /[A-Za-z0-9\-_.]{128,}/)

This should match any JWT with atleast 128 char…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ASaiAnudeep
Comment options

@NorseJedi
Comment options

Answer selected by NorseJedi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants