Boghyon Hoffmann
Boghyon Hoffmann

Reputation: 18064

OPA5: Purpose of "and" in promise returned from waitFor

I'm kind of new to integration testing with OPA5, so I was reading a tutorial on the dev guide. There is this and included before iTeardownMyAppFrame() in the first sample code.

// Assertions
Then.onThePostPage.theTitleShouldDisplayTheName("Jeans").and.iTeardownMyAppFrame();

I was wondering what and exactly does but I couldn't find any documentation about it. The and property is included in the promise returned from the waitFor method of sap.ui.test.Opa5, as the image below shows:

enter image description here

From API reference:

{jQuery.promise} A promise that gets resolved on success

So I looked at the jQuery documentation about the promise but I couldn't find anything about and there either which indicates that the returned jQuery.promise is extended by OPA5.

iTeardownMyAppFrame without and worked fine as I assumed (since it always returns the same promise). So what is the purpose of and? Is it just syntactic sugar? Did someone experience errors because of the missing and? Is there any documentation about it that I overlooked?


PS: Let me know if you need a minimal example of integration testing with OPA5.

Upvotes: 1

Views: 560

Answers (2)

Max
Max

Reputation: 1342

The '.and' is a pure syntactical sugar to make the action sound as a fluent English sentence. It is questionable whether using it is a good practice or antipattern.

Upvotes: 1

Sharon
Sharon

Reputation: 146

I am not just beginning with OPA myself but as far as I know, the .and. is used for chaining. So it is the same as using two Then statements.

Upvotes: 6

Related Questions