Are what Cypress doc calls "subjects" JS generators, JS promises, regular JS objects or something else? #26749
Replies: 1 comment
-
Hello @JacquesRobin, I understand that you're feeling confused about some of the jargon used in the Cypress.io documentation. I'll do my best to clarify the concepts for you. In Cypress, when the documentation states that Cypress commands "yield" their result rather than returning them, it does not refer to JavaScript generator functions or objects using the The term "subject" in Cypress refers to the implicit argument passed through the Cypress command chains. It represents the target element or elements on which the subsequent commands will operate. In other words, the subject is the element(s) that you're interacting with using Cypress commands. It doesn't directly relate to the concept of subjects in subject-oriented programming or the observer pattern. Regarding the To answer your questions directly:
I hope this clarifies the concepts for you. If you have any further questions or need additional clarification, feel free to ask. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Cypress.io noob getting confused with the jargon used in the doc.
The doc says that cypress commands yield their result rather than returning them. Should I infer from that that the implicit argument that is passed through the cypress call chains is a JS Generator Function or JS Generator Object? Or do they used the word "yield" to refer to a different concept than the one denoted by the Vanilla JS keyword "yield"?
The doc seems to call this implicit argument a "subject", but it does not seem to have anything to do with the concept of subject in subject-oriented programming, nor with the concept of subject in the observer pattern, so does this choice of word does refer to another CS concept that I have never heard of?
The "then()" command seems to transform a yielded value into a returned value so that one can assign it to a variable passed as explicit argument the next command in the chain. Should I infer from that that the implicit argument that is passed through the cypress call chain is what Vanilla JS calls a Promise object?
So I am wondering whether the implicit argument called "subject" passed through the cypress command chains is:
Any clarification much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions