Ember-cli tests run from built-in hadrons

I have an ember-cli project with some add-ons created using ember generate in-repo-addon foo

When I run ember serve , ember-cli serves my addon assets by combining /app and /lib/foo/app in /dist/assets/app.js .

I was expecting something similar to tests. When I run ember test or browse http://localhost:4200/tests , I see only the created JSHint tests for the main application. Everything that I create in /lib/foo/tests is ignored.

Where can I create tests for the addon and how to run them?

+6
source share
2 answers

There is an Ember-CLI function, which is not very well documented (luck of finds), which I used for our built-in repo add-on, which includes adding β€œtest support” to your add-on.

In your case, you can do something similar in your addon

 foo |-- test-support |-- helpers | |-- common-helper.js | |-- anther-common-helper.js |-- unit |-- models |-- user-test.js 

I use something very similar without any problems. It saved a lot of time for us, hope it helps

+5
source

If you use the ember generator to create your tests in the add-on, you will see where the files are created - this is the same file structure as in the regular ember-cli project:

 my-addon |-- tests |-- integration |-- my-integration-test 

You also run tests for the add-on in the same way as for a regular ember-cli project, using ember test or starting an ember server in the root directory of your add-on and switching to http://localhost:4200/tests .

The addon creates a dummy application to host your test addon. You can find out more about the official Ember-cli documentation: http://www.ember-cli.com/extending/#testing-the-addon-with-qunit

0
source

All Articles