diff --git a/CHANGELOG.md b/CHANGELOG.md index 89fc0ceb..72220cb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Unreleased + +* `environments` configuration option. + # 0.0.2 * Add the `testSelector` test helper that makes generating `data` attribute diff --git a/README.md b/README.md index 1abfa1af..89905653 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,25 @@ delivered__: ``` +## Configuartion +To modify the default configuration, place a block called `ember-test-selectors` +in your `ember-cli-build.js` file. + +### Options + +`environments` +Defines the environments in which you want the test selectors to be removed. +By default, selectors are only removed in the `production` environment. You +might also want to remove them in other staging environments for testing. + +```javascript +var app = new EmberApp({ + 'ember-test-selectors': { + environments: ['production', 'staging'] + } +}); +``` + ## Test Helpers `ember-test-selectors` comes with a test helper that can be used in acceptance diff --git a/index.js b/index.js index 6367ce5b..30fadc76 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,20 @@ /*jshint node:true*/ -var StringTestSelectorsTransform = require('./strip-test-selectors'); +var _includes = require('lodash/includes'); module.exports = { name: 'test-selectors', - included: function() { - if (this.app.env === 'production') { - this.app.registry.add('htmlbars-ast-plugin', { + setupPreprocessorRegistry: function(type, registry) { + var appOptions = registry.app.options || {}; + var addonOptions = appOptions['ember-test-selectors'] || {}; + var environments = addonOptions.environments || ['production']; + + if (_includes(environments, registry.app.env)) { + var StripTestSelectorsTransform = require('./strip-test-selectors'); + + registry.add('htmlbars-ast-plugin', { name: 'strip-test-selectors', - plugin: StringTestSelectorsTransform + plugin: StripTestSelectorsTransform }); } }