EmberJS-Test Helpers



Test Helpers

When you create an application using Ember, it needs to tested. To perform acceptance testing, Ember provides two types of testing helpers −

  • asynchronous

  • synchronous

Asynchronous Helpers

Asynchronous helpers provide asynchronous behaviour within an application which makes easier way to write tests. Asynchronous helpers run the tests in a chain in which each one is called after the previous one finishes.

The below list shows some of the asynchronous helpers in Ember:

  • click(selector): It provides click event whenever an element triggers click action on it and when async behaviour is complete, it returns a promise.

  • fillIn(selector, text): It fills the text in the selected input and when async behaviour is complete, it returns a promise.

  • keyEvent(selector, type, keyCode): It defines different key event types such as keydown, keypress, keyup on element specified by the selector.

  • triggerEvent(selector, type, options) : It triggers the events such as blur, double click etc on the element specified by the selector.

  • visit(url): It visits the route and when async behaviour is complete, it returns a promise.

Synchronous Helpers

Synchronous helpers perform when these are triggered immediately.

The below list shows some of the synchronous helpers in Ember −

  • currentPath() : It defines the current path.

  • currentRouteName() : It defines the current route name.

  • currentURL() : It defines the current URL.

  • find(selector, context) : It is used to find an element within the root element of an application and context.

There are other helpers in Ember.js as shown below −

S.N.Helper Types & Description
1 Wait Helpers
It waits for the asynchronous helpers to complete the task.
2 Custom Test Helpers
It is used to create own test helper.
Advertisements