Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 464
Daniel Hilgarth Avatar asked Jul 13 '26 13:07

Daniel Hilgarth


1 Answers

TestCafe doesn't provide API for that for now. Here is a feature suggestion in the TestCafe Github repository: Provide an ability to add custom actions to the test controller. You can vote for it by adding your +1 reaction.

like image 132
Alexander Moskovkin Avatar answered Jul 15 '26 09:07

Alexander Moskovkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!