-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 Loggable options to its() / invoke() command #5519
Conversation
Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.
PR Review ChecklistIf any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'. User Experience
Functionality
Maintainability
Quality
Internal
|
fix: only set logger config once. afterwards other commands can overwrite the logger config as done in line 322 remove unused error message (usage was removed in a former commit) remove test that is unnecessary now
Hey @gabbersepp, I see some tests failing around the If there is still work being done, add the Let us know if you have any questions we can help with in the meantime! |
Hey, I don't understand how the "logs immediately before resolving" can fail. What I have done and what I do not understand how this can work:
How can this happen? Line 175 only calls Cypress.Log() without passing anything but nevertheless line 892 is called? @jennifer-shehane maybe you can give me a hint here. |
Btw if I use following test instead: it "logs immediately before resolving", (done) ->
#cy.on "log:added", (attrs, log) ->
# if log.get("name") is "its"
# expect(log.get("state")).to.eq("pending")
# expect(log.get("message")).to.eq ".foo"
# done()
cy.noop({foo: "foo"}).its("foo").then ->
lastLog = @lastLog
expect(lastLog.get("message")).to.eq(".foo")
done() everything is green //Edit: Seems strange: Both, the log received in the event and the log in lastLog are the same but the message differs. |
ok. finally fixed the test. :-) |
Great. Sorry we couldn't get any eyes on this sooner to help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this manually and it worked when used as designed.
I fould a few error edge cases that need better handling.
-
If someone were to call
.invoke({ log: false })
and forget the second argument an error is thrown that would not be clear to the user what they did wrong.Can you add special error handling for this case with a message informing that they need to pass in a function argument and add a test for this also?
-
If I pass a non-String as the 2nd argument after passing the options Object
.invoke({ log: false }, 13)
, the error message incorrectly tells me that the 1st argument only accepts String, it should say 'Second'. Can you add a test for this also? -
If I pass a non-Object to
its
options argument.its('length', 'foo')
the function of its no longer functions and returns undefined. This should throw an error saying we only accept an options Object as the second argument - add a test for this. -
Passing a non-Object or String as the first argument to invokes causes unexpected results when continuing to chain the return value of the invoke
.invoke(13, 'show')
. We should throw if the first argument is not an Object or String - add a test for this also.
6eb0953
to
1503393
Compare
1503393
to
e0c8d13
Compare
Thanks. There where some bugs in it. Hopefully I fixed all of them. Personally I would prefer to split up this spec file into several smaller ones as now the file has about 1500 lines of code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to resolve merge conflicts first
@bahmutov But after reading through #5755 I am not sure if the changes made on |
It will make the contract a little weird, but the way you have it here is really the only way I can see to do it. 👍 on this change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a minor editing to the wording I added. Otherwise this looks good.
* add Loggable options to its() command * add test for new Loggable option for its() * add loggable options to invoke() * add type definition fix: only set logger config once. afterwards other commands can overwrite the logger config as done in line 322 remove unused error message (usage was removed in a former commit) remove test that is unnecessary now * add check if its() was passed additional arguments next to options * try to fix test * do not log 'this' context * from review: add additional tests and fix some edge cases * add tests for combination of loggable options and numeric index * fix wrong indentation * write as 'functionName' and 'propertyName' to match other error message * Update tests to reflect newly worded errors Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
* add Loggable options to its() command * add test for new Loggable option for its() * add loggable options to invoke() * add type definition fix: only set logger config once. afterwards other commands can overwrite the logger config as done in line 322 remove unused error message (usage was removed in a former commit) remove test that is unnecessary now * add check if its() was passed additional arguments next to options * try to fix test * do not log 'this' context * from review: add additional tests and fix some edge cases * add tests for combination of loggable options and numeric index * fix wrong indentation * write as 'functionName' and 'propertyName' to match other error message * Update tests to reflect newly worded errors Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
its
command doesn't accept a log option (logging can't be disabled) #1450User facing changelog
The commands
.its()
and.invoke()
now accept an options object of typeLoggable
to indicate that logging should be skipped.Additional details
This change does not break any existing implementations. By default logging is enabled.
How has the user experience changed?
its Before
its After
invoke Before
invoke After
PR Tasks
cypress-documentation
? add docu for new options argument of its() cypress-documentation#2205type definitions
?Edited by @jennifer-shehane to add before and after headings for its and invoke + add invoke change to changelog.