-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to better cookie assertions #259
Comments
This looks like a great idea to me. @austince WDYT? @schrodervictor it'd be good to have |
I think this would be great too! I'm just also wondering about the I'm not sure if this is possible, but would it be better to just improve access to cookies? const fooGroupCookieInfo = expect(req).to.have.cookie('group-foo', 'a')
expect(fooGroupCookieInfo).to.have.property('Path', '/') |
@keithamus, that's exactly what I thought. If the assertion isn't mentioning an certain cookie attribute, we should consider it not relevant for the test case presented.
@austince, I first thought them as exact matches, but doing regexp would be straight forward. Some attributes, like
You are probably right, as it would be more flexible, but I'm not sure how to do it. Do you have experience implementing this kind of enhancement? If yes, could you point me some directions? The only detail I disagree is that I would definitely not capture the return value of a previous assertion and pass it through another expect(req).to.have.cookie('group-foo', 'a').that.has.property('Path', '/');
expect(req).to.have.cookie('group-foo', 'a').that.has.property('HttpOnly'); Anyways, I would say that the original proposal is fully compatible with this one and we could maybe have both. As for the first one, I would basically already know how to do it. This later one has way nicer interface and flexibility, but would require more research. We could do it in two steps. What do you think? More inputs? Can I safely start? |
Please go ahead! I look forward to seeing the PR! |
I think the chaining option makes sense and will be easier to use as well! You may want to do exact matches for now and leave the regex/ ranges for a later extension, but totally up to you and thanks for the thorough plan! |
@austince and @keithamus, the pull request is out, but it seems to have a problem with Github CI. Judging by the error message, it doesn't look like anything related to code itself, but more like configuration error or a third party thing (server error, 500...). Not sure. Could you please take a look? If any action is needed from my side, just let me know. |
Hello!
We are using this library quite extensively, but we have the need to assert aspects about the cookies being set by the server, like
Domain
,Max-Age
andPath
, but I could see in the source that these are not currently supported.I gladly offer myself to implement this feature and open the respective pull request, as I would need to fork and implement it anyways, but I'm opening this issue to ask if the contribution would be accepted and also to discuss the preferred interface for this kind of assertion.
My first idea would be to implement it as
expect(req).to.have.cookie(key, value, info);
, keeping bothvalue
andinfo
as optional arguments to not break backwards compatibility. The argumentinfo
would be an object with the additional information to assert about the cookie. In my current example, it would be something like this:Sounds good?
The text was updated successfully, but these errors were encountered: