npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ember-cli-test-addons-in-app

v0.0.1

Published

Run your Ember addon tests in your app context

Downloads

9

Readme

Ember-cli-test-addons-in-app

This README outlines the details of collaborating on this Ember addon.

Background

In many Ember applications especially in those meant for enterprise sector Ember apps being developed are split into addons according to their purpose. There is also a need to run tests for those private sourced addons not just separately in the addon itself but also within the context of the application using those addon. This addon suits that purpose and allows to specify your app addons for which you want to concatenate the tests with your app in development and test builds by providing a config in ember-cli-build.js :

module.exports = function (defaults) {
  var app = new EmberApp(defaults, {
    emberCliAddonTests: [
      'my-private-addon',
      'my-other-private-addon'
    ]
  });

  return app.toTree();
};

Such config would add my-private-addon and my-other-private-addon tests to your app tests and run them in the test context of your application.

Installation

  • ember install ember-cli-test-addons-in-app

Running tests only in addon context

After concatenation some of addon tests would fail as some addon pieces might be extended or reopened in the app or generally the app context might be different from the one in the addon. To mitigate those issues the special test helpers are provided that would help to run some of the tests only in proper context:

import { 
  moduleForComponent, 
  testInModule 
} from 'ember-cli-test-addons-in-app';
 
import { test } from 'ember-qunit';
 
moduleForComponent('some component', 'Integration | Component | some component', {
  integration: true,
  modulePrefixes: ['my-private-addon']
});
 
testInModule('things tested here would work only in addon context', function(assert) {
  
  // test code omitted
  
});
 
test('things tested here would work in both addon context and app context', function(assert) {
  
  // test code omitted
  
});

In the example above special moduleForComponent is used instead of traditional provided by ember-qunit. This moduleForComponent takes advantage of modulePrefixes property that you have to specify in your callbacks object and it should be an Array of modules.

After you specify your modulePrefixes you are free to use the testInModule helper instead of test. testInModule would make sure that the test would run only in the context of addons or apps specified in modulePrefixes and gets ignored in other contexts. The modulePrefixes provided in callbacks are compared to the one provided within your config/environment.js to make that decision.

The test that should always run should be ran with test from ember-qunit

This addon provides the following helpers:

import { 
  moduleForComponent,
  module,
  moduleForModel,
  moduleFor,
  testInModule 
} from 'ember-cli-test-addons-in-app';

Caveats

  • For now the default behaviour of tests concatenation is overwrite. Meaning if you have tests/unit/my-awesome-test.js in your my-private-addon addon and you also have tests/unit/my-awesome-test.js in the consuming app that uses ember-cli-test-addons-in-app to concatenate tests from my-private-addon you would end up with just a single tests/unit/my-awesome-test.js originating from your app and not from my-private-addon. ember-cli-test-addons-in-app does not currently provide any ways to alter this behaviour with renaming tests from addons but we are open for PR's for implementations of such feature.

  • As qunit and ember-qunit module helper runs with no context there is no way to know what app/addon context we are using at runtime so the original module is swapped for call to moduleFor with config:environment as the name. This alters the test context behaviour and bootstraps isolated app container as moduleFor normally does. This allows to mute the tests for addon Mixins which are reopened in the app or other addons.

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.