Search code examples
ember.jsember-addon

ember addons test-support directory


I've some test helpers in my addon. I want to:

  1. use these helpers for my addon's own tests.
  2. make these helpers available to my addon's users, for testing their own codes.

In the documentation, it is said that test-support can be used to satisfy the second requirement mentioned above; but I couldn't find a way to make it work for both.


Solution

  • The docs say "merged with the application’s tests/",

    An applications test-helpers reside in test/helpers/, any helper specified here should be registered automatically.

    When sharing an addons test-helper, make sure it resides in test-support/helpers,

    Once the directory get merged, the file should end up in the tests/helpers directory and be registered automatically.

    As a reference one could take a look at the emberx-select addon, A "select"-helper is shared using the same method specified in this answer.