lundi 4 septembre 2017

Extend TestController / TestControllerPromise

I am writing my E2E tests with test cafe. The code I am testing is a library that is loaded into other websites and first needs to initialize itself. So every one of my tests starts with the same code:

t.switchToIframe(iframeSelector)
 .expect(loginSelectorSpinner).exists).ok({timeout: 3000}) // wait for login start
 .expect(loginSelectorSpinner).exists).notOk({timeout: 5000}) // wait for login finish

I would like to move this into helper methods that I can chain like the built-in methods.
So my code would look like this:

t.waitForLoginFinish()
 .except(whatever)...

How can I achieve this?

Aucun commentaire:

Enregistrer un commentaire