Repository: ember-cli/ember-cli (js)

Issue:
Incorrect test environment when using storeConfigInMeta: false
When using `storeConfigInMeta: false` the testing environment is `"development"` instead of `"test"`. Steps to reproduce:
- Set `storeConfigInMeta: false`
- `ember serve`
- Visit http://localhost:4200/tests/index.html
- In the console, `require('my-app/config/environment').default.environment` is `development` instead of `test`.

In acceptance tests, this means that the router's `locationType` is not set to `"none"` which is really annoying to work with.


Pull request:
EmberApp: Overwrite `app/config/environment` in `tests.js`
This PR fixes the content of the `my-app/config/environment` module when `storeConfigInMeta: false` is used and http://localhost:4200/tests/ is visited. A similarly named module will be generated in the `tests.js` file which overwrites the one contained in `my-app.js`.

Overwriting in `test-support.js` unfortunately does not work because `test-support.js` is imported before `my-app.js` which would overwrite the config in the wrong way.

This is needed to make `setApplication()` and http://localhost:4200/tests/ work well together when `storeConfigInMeta: false` is used.

Resolves #4535

/cc @stefanpenner @kellyselden 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2339f88cf..3b42352e9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,59 +1,44 @@
 # ember-cli Changelog
 
-## v3.0.0-beta.1
+## 2.18.0-beta.2
 
 The following changes are required if you are upgrading from the previous
 version:
 
 - Users
-  + [`ember new` diff](https://github.com/ember-cli/ember-new-output/compare/v2.18.0...v3.0.0-beta.1)
+  + [`ember new` diff](https://github.com/ember-cli/ember-new-output/compare/v2.18.0-beta.1...v2.18.0-beta.2)
   + Upgrade your project's ember-cli version - [docs](https://ember-cli.com/user-guide/#upgrading)
 - Addon Developers
-  + [`ember addon` diff](https://github.com/ember-cli/ember-addon-output/compare/v2.18.0...v3.0.0-beta.1)
+  + [`ember addon` diff](https://github.com/ember-cli/ember-addon-output/compare/v2.18.0-beta.1...v2.18.0-beta.2)
 - Core Contributors
   + No changes required
 
 #### Community Contributions
 
-- [#7522](https://github.com/ember-cli/ember-cli/pull/7522) utilities: Remove deprecated `deprecateUI()` function [@Turbo87](https://github.com/Turbo87)
-- [#7502](https://github.com/ember-cli/ember-cli/pull/7502) Cleanup and correct node-support.md. [@ember-cli](https://github.com/ember-cli)
-- [#7487](https://github.com/ember-cli/ember-cli/pull/7487) [BUGFIX] give `ember new` error messages consistent color [@GavinJoyce/gj](https://github.com/GavinJoyce/gj)
-- [#7479](https://github.com/ember-cli/ember-cli/pull/7479) Improve default addon README [@Turbo87](https://github.com/Turbo87)
-- [#7512](https://github.com/ember-cli/ember-cli/pull/7512) fix alpha ordering in npmignore [@ember-cli](https://github.com/ember-cli)
-- [#7520](https://github.com/ember-cli/ember-cli/pull/7520) Remove deprecated commands [@Turbo87](https://github.com/Turbo87)
-- [#7523](https://github.com/ember-cli/ember-cli/pull/7523) Remove deprecated code from `EmberApp` class [@Turbo87](https://github.com/Turbo87)
-- [#7524](https://github.com/ember-cli/ember-cli/pull/7524) Remove deprecated `Blueprint` code [@Turbo87](https://github.com/Turbo87)
-- [#7525](https://github.com/ember-cli/ember-cli/pull/7525) Remove deprecated `Project` and `Addon` code [@Turbo87](https://github.com/Turbo87)
-- [#7527](https://github.com/ember-cli/ember-cli/pull/7527) EmberApp: Remove deprecated `contentFor()` hooks [@Turbo87](https://github.com/Turbo87)
+- [#7474](https://github.com/ember-cli/ember-cli/pull/7474) Give plugins and extends their own lines [@rwwagner90](https://github.com/rwwagner90)
+- [#7475](https://github.com/ember-cli/ember-cli/pull/7475) don't treat strings as regex in insertIntoFile [@kellyselden](https://github.com/kellyselden)
+- [#7477](https://github.com/ember-cli/ember-cli/pull/7477) Restore `separator: '\n;'` to vendor JS concat [@kellyselden/lenny](https://github.com/kellyselden/lenny)
+- [#7478](https://github.com/ember-cli/ember-cli/pull/7478) Remove obsolete CONFIG_CACHING feature flag [@Turbo87](https://github.com/Turbo87)
+- [#7481](https://github.com/ember-cli/ember-cli/pull/7481) NpmInstallTask: `useYarn` from constructor args [@lennyburdette](https://github.com/lennyburdette)
 
 Thank you to all who took the time to contribute!
 
 
-## v2.18.0
+## 2.18.0-beta.1
 
 The following changes are required if you are upgrading from the previous
 version:
 
 - Users
-  + [`ember new` diff](https://github.com/ember-cli/ember-new-output/compare/v2.17.2...v2.18.0)
+  + [`ember new` diff](https://github.com/ember-cli/ember-new-output/compare/v2.17.0...v2.18.0-beta.1)
   + Upgrade your project's ember-cli version - [docs](https://ember-cli.com/user-guide/#upgrading)
 - Addon Developers
-  + [`ember addon` diff](https://github.com/ember-cli/ember-addon-output/compare/v2.17.2...v2.18.0)
+  + [`ember addon` diff](https://github.com/ember-cli/ember-addon-output/compare/v2.17.0...v2.18.0-beta.1)
 - Core Contributors
   + No changes required
 
 #### Community Contributions
 
-- [#7489](https://github.com/ember-cli/ember-cli/pull/7489) Fix regression with scoped package name mismatches [@rwwagner90](https://github.com/rwwagner90)
-- [#7507](https://github.com/ember-cli/ember-cli/pull/7507) Ensure testing honors config/environment settings. [@rwjblue](https://github.com/rwjblue)
-- [#7513](https://github.com/ember-cli/ember-cli/pull/7513) fix alpha ordering in npmignore [@kellyselden](https://github.com/kellyselden)
-- [#7516](https://github.com/ember-cli/ember-cli/pull/7516) Fix `ember new --yarn` not using yarn [@Turbo87](https://github.com/Turbo87)
-- [#7529](https://github.com/ember-cli/ember-cli/pull/7529) Backport & fixup linting changes. [@rwjblue](https://github.com/rwjblue)
-- [#7474](https://github.com/ember-cli/ember-cli/pull/7474) Give plugins and extends their own lines [@rwwagner90](https://github.com/rwwagner90)
-- [#7475](https://github.com/ember-cli/ember-cli/pull/7475) don't treat strings as regex in insertIntoFile [@kellyselden](https://github.com/kellyselden)
-- [#7477](https://github.com/ember-cli/ember-cli/pull/7477) Restore `separator: '\n;'` to vendor JS concat [@kellyselden/lenny](https://github.com/kellyselden/lenny)
-- [#7478](https://github.com/ember-cli/ember-cli/pull/7478) Remove obsolete CONFIG_CACHING feature flag [@Turbo87](https://github.com/Turbo87)
-- [#7481](https://github.com/ember-cli/ember-cli/pull/7481) NpmInstallTask: `useYarn` from constructor args [@lennyburdette](https://github.com/lennyburdette)
 - [#7395](https://github.com/ember-cli/ember-cli/pull/7395) Make "testdouble" dependency optional in MockProcess class [@ro0gr](https://github.com/ro0gr)
 - [#7382](https://github.com/ember-cli/ember-cli/pull/7382) add option to not create file [@kellyselden](https://github.com/kellyselden)
 - [#7385](https://github.com/ember-cli/ember-cli/pull/7385) remove node 7 testing [@kellyselden](https://github.com/kellyselden)
diff --git a/blueprints/app/files/.eslintrc.js b/blueprints/app/files/.eslintrc.js
index 9a0b8badb..e6c3f9c35 100644
--- a/blueprints/app/files/.eslintrc.js
+++ b/blueprints/app/files/.eslintrc.js
@@ -19,17 +19,13 @@ module.exports = {
   overrides: [
     // node files
     {
-      files: [<% if (blueprint !== 'app') { %>
-        'index.js',<% } %>
+      files: [
+        'index.js',
         'testem.js',
         'ember-cli-build.js',
-        'config/**/*.js'<% if (blueprint !== 'app') { %>,
-        'tests/dummy/config/**/*.js'<% } %>
-      ],<% if (blueprint !== 'app') { %>
-      excludedFiles: [
-        'app/**',
-        'addon/**'
-      ],<% } %>
+        'config/**/*.js',
+        'tests/dummy/config/**/*.js'
+      ],
       parserOptions: {
         sourceType: 'script',
         ecmaVersion: 2015
diff --git a/blueprints/app/files/package.json b/blueprints/app/files/package.json
index ea0aa46f0..ef2edb601 100644
--- a/blueprints/app/files/package.json
+++ b/blueprints/app/files/package.json
@@ -31,11 +31,11 @@
     "ember-cli-shims": "^1.2.0",
     "ember-cli-sri": "^2.1.0",
     "ember-cli-uglify": "^2.0.0",
-    "ember-data": "~3.0.0-beta.1",
+    "ember-data": "~2.18.0-beta.1",
     "ember-export-application-global": "^2.0.0",
     "ember-load-initializers": "^1.0.0",
     "ember-resolver": "^4.0.0",
-    "ember-source": "~3.0.0-beta.1<% if (welcome) { %>",
+    "ember-source": "~2.18.0-beta.3<% if (welcome) { %>",
     "ember-welcome-page": "^3.0.0<% } %>",
     "eslint-plugin-ember": "^5.0.0",
     "loader.js": "^4.2.3"
diff --git a/lib/broccoli/app-prefix.js b/lib/broccoli/app-prefix.js
index 3918c74e4..ee5590c15 100644
--- a/lib/broccoli/app-prefix.js
+++ b/lib/broccoli/app-prefix.js
@@ -1,1 +1,3 @@
 "use strict";
+
+{{content-for 'app-prefix'}}
diff --git a/lib/broccoli/app-suffix.js b/lib/broccoli/app-suffix.js
index e69de29bb..a51f77ab5 100644
--- a/lib/broccoli/app-suffix.js
+++ b/lib/broccoli/app-suffix.js
@@ -0,0 +1,1 @@
+{{content-for 'app-suffix'}}
diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js
index e5dc7ddec..ce7098288 100644
--- a/lib/broccoli/ember-app.js
+++ b/lib/broccoli/ember-app.js
@@ -1221,6 +1221,33 @@ class EmberApp {
     return this._cachedEmberCLITree;
   }
 
+  /**
+    @private
+    @method _testAppConfigTree
+    @return
+  */
+  _testAppConfigTree() {
+    if (!this._cachedTestAppConfigTree) {
+      let files = ['app-config.js'];
+
+      let emberCLITree = new ConfigReplace(new UnwatchedDir(__dirname), this._configTree(), {
+        configPath: path.join(this.name, 'config', 'environments', `test.json`),
+        files,
+
+        patterns: this._configReplacePatterns(),
+      });
+
+      this._cachedTestAppConfigTree = new Funnel(emberCLITree, {
+        files,
+        srcDir: '/',
+        destDir: '/vendor/ember-cli/',
+        annotation: 'Funnel (test-app-config-tree)',
+      });
+    }
+
+    return this._cachedTestAppConfigTree;
+  }
+
   /**
     Returns the tree for the app and its dependencies
 
@@ -1287,6 +1314,7 @@ class EmberApp {
     let appTestTrees = [].concat(
       this.hinting && this.lintTestTrees(),
       this._processedEmberCLITree(),
+      this._testAppConfigTree(),
       coreTestTree
     ).filter(Boolean);
 
@@ -1298,7 +1326,7 @@ class EmberApp {
     return this._concatFiles(appTestTrees, {
       inputFiles: [`${this.name}/tests/**/*.js`],
       headerFiles: ['vendor/ember-cli/tests-prefix.js'],
-      footerFiles: ['vendor/ember-cli/tests-suffix.js'],
+      footerFiles: ['vendor/ember-cli/app-config.js', 'vendor/ember-cli/tests-suffix.js'],
       outputFile: this.options.outputPaths.tests.js,
       annotation: 'Concat: App Tests',
     });
@@ -1827,6 +1855,8 @@ class EmberApp {
    */
   contentFor(config, match, type) {
     let content = [];
+    let deprecatedHooks = ['app-prefix', 'app-suffix', 'vendor-prefix', 'vendor-suffix'];
+    let deprecate = this.project.ui.writeDeprecateLine.bind(this.project.ui);
 
     // This normalizes `rootURL` to the value which we use everywhere inside of Ember CLI.
     // This makes sure that the user doesn't have to account for it in application code.
@@ -1844,6 +1874,7 @@ class EmberApp {
     content = this.project.addons.reduce((content, addon) => {
       let addonContent = addon.contentFor ? addon.contentFor(type, config, content) : null;
       if (addonContent) {
+        deprecate(`The \`${type}\` hook used in ${addon.name} is deprecated. The addon should generate a module and have consumers \`require\` it.`, deprecatedHooks.indexOf(type) === -1);
         return content.concat(addonContent);
       }
 
diff --git a/lib/broccoli/vendor-prefix.js b/lib/broccoli/vendor-prefix.js
index 5a31b160c..ea8843249 100644
--- a/lib/broccoli/vendor-prefix.js
+++ b/lib/broccoli/vendor-prefix.js
@@ -1,2 +1,4 @@
 window.EmberENV = {{EMBER_ENV}};
 var runningTests = false;
+
+{{content-for 'vendor-prefix'}}
diff --git a/lib/broccoli/vendor-suffix.js b/lib/broccoli/vendor-suffix.js
index e69de29bb..cbe2d02d2 100644
--- a/lib/broccoli/vendor-suffix.js
+++ b/lib/broccoli/vendor-suffix.js
@@ -0,0 +1,1 @@
+{{content-for 'vendor-suffix'}}
diff --git a/lib/experiments/index.js b/lib/experiments/index.js
index 0d31f6eec..7a503afc9 100644
--- a/lib/experiments/index.js
+++ b/lib/experiments/index.js
@@ -1,6 +1,16 @@
 'use strict';
+const symbol = require('../utilities/symbol');
+const getCallerFile = require('get-caller-file');
+const deprecate = require('../utilities/deprecate');
 
-let experiments = {};
+let experiments = {
+  MODULE_UNIFICATION: symbol('module-unification'),
+  get INSTRUMENTATION() {
+    deprecate(`\`experiments.INSTRUMENTATION\` is deprecated now that the feature has landed, use \`instrumentation\` method on your addon instead. Required from: \n${getCallerFile()}`, true);
+
+    return 'instrumentation';
+  },
+};
 
 Object.freeze(experiments);
 
diff --git a/package.json b/package.json
index 1815d400a..0bdeeb553 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "ember-cli",
-  "version": "3.0.0-beta.1",
+  "version": "2.18.0-beta.2",
   "description": "Command line tool for developing ambitious ember.js apps",
   "keywords": [
     "app",


Test patch:
diff --git a/tests/fixtures/addon/npm/.eslintrc.js b/tests/fixtures/addon/npm/.eslintrc.js
index 1c65e6db0..6ed6f7478 100644
--- a/tests/fixtures/addon/npm/.eslintrc.js
+++ b/tests/fixtures/addon/npm/.eslintrc.js
@@ -26,10 +26,6 @@ module.exports = {
         'config/**/*.js',
         'tests/dummy/config/**/*.js'
       ],
-      excludedFiles: [
-        'app/**',
-        'addon/**'
-      ],
       parserOptions: {
         sourceType: 'script',
         ecmaVersion: 2015
diff --git a/tests/fixtures/addon/npm/package.json b/tests/fixtures/addon/npm/package.json
index 9bf8480aa..44b4beef8 100644
--- a/tests/fixtures/addon/npm/package.json
+++ b/tests/fixtures/addon/npm/package.json
@@ -38,7 +38,7 @@
     "ember-export-application-global": "^2.0.0",
     "ember-load-initializers": "^1.0.0",
     "ember-resolver": "^4.0.0",
-    "ember-source": "~3.0.0-beta.1",
+    "ember-source": "~2.18.0-beta.3",
     "eslint-plugin-ember": "^5.0.0",
     "eslint-plugin-node": "^5.2.1",
     "loader.js": "^4.2.3"
diff --git a/tests/fixtures/addon/yarn/.eslintrc.js b/tests/fixtures/addon/yarn/.eslintrc.js
index 1c65e6db0..6ed6f7478 100644
--- a/tests/fixtures/addon/yarn/.eslintrc.js
+++ b/tests/fixtures/addon/yarn/.eslintrc.js
@@ -26,10 +26,6 @@ module.exports = {
         'config/**/*.js',
         'tests/dummy/config/**/*.js'
       ],
-      excludedFiles: [
-        'app/**',
-        'addon/**'
-      ],
       parserOptions: {
         sourceType: 'script',
         ecmaVersion: 2015
diff --git a/tests/fixtures/addon/yarn/package.json b/tests/fixtures/addon/yarn/package.json
index f8a1099b5..b5f916d5d 100644
--- a/tests/fixtures/addon/yarn/package.json
+++ b/tests/fixtures/addon/yarn/package.json
@@ -38,7 +38,7 @@
     "ember-export-application-global": "^2.0.0",
     "ember-load-initializers": "^1.0.0",
     "ember-resolver": "^4.0.0",
-    "ember-source": "~3.0.0-beta.1",
+    "ember-source": "~2.18.0-beta.3",
     "ember-welcome-page": "^3.0.0",
     "eslint-plugin-ember": "^5.0.0",
     "eslint-plugin-node": "^5.2.1",
diff --git a/tests/fixtures/app/npm/.eslintrc.js b/tests/fixtures/app/npm/.eslintrc.js
index 1f7a6c0bd..7d328870e 100644
--- a/tests/fixtures/app/npm/.eslintrc.js
+++ b/tests/fixtures/app/npm/.eslintrc.js
@@ -20,9 +20,11 @@ module.exports = {
     // node files
     {
       files: [
+        'index.js',
         'testem.js',
         'ember-cli-build.js',
-        'config/**/*.js'
+        'config/**/*.js',
+        'tests/dummy/config/**/*.js'
       ],
       parserOptions: {
         sourceType: 'script',
diff --git a/tests/fixtures/app/npm/package.json b/tests/fixtures/app/npm/package.json
index 67c5b4275..82fe8addd 100644
--- a/tests/fixtures/app/npm/package.json
+++ b/tests/fixtures/app/npm/package.json
@@ -31,11 +31,11 @@
     "ember-cli-shims": "^1.2.0",
     "ember-cli-sri": "^2.1.0",
     "ember-cli-uglify": "^2.0.0",
-    "ember-data": "~3.0.0-beta.1",
+    "ember-data": "~2.18.0-beta.1",
     "ember-export-application-global": "^2.0.0",
     "ember-load-initializers": "^1.0.0",
     "ember-resolver": "^4.0.0",
-    "ember-source": "~3.0.0-beta.1",
+    "ember-source": "~2.18.0-beta.3",
     "eslint-plugin-ember": "^5.0.0",
     "loader.js": "^4.2.3"
   },
diff --git a/tests/fixtures/app/yarn/.eslintrc.js b/tests/fixtures/app/yarn/.eslintrc.js
index 1f7a6c0bd..7d328870e 100644
--- a/tests/fixtures/app/yarn/.eslintrc.js
+++ b/tests/fixtures/app/yarn/.eslintrc.js
@@ -20,9 +20,11 @@ module.exports = {
     // node files
     {
       files: [
+        'index.js',
         'testem.js',
         'ember-cli-build.js',
-        'config/**/*.js'
+        'config/**/*.js',
+        'tests/dummy/config/**/*.js'
       ],
       parserOptions: {
         sourceType: 'script',
diff --git a/tests/fixtures/app/yarn/package.json b/tests/fixtures/app/yarn/package.json
index a5f729e27..c894b1a92 100644
--- a/tests/fixtures/app/yarn/package.json
+++ b/tests/fixtures/app/yarn/package.json
@@ -31,11 +31,11 @@
     "ember-cli-shims": "^1.2.0",
     "ember-cli-sri": "^2.1.0",
     "ember-cli-uglify": "^2.0.0",
-    "ember-data": "~3.0.0-beta.1",
+    "ember-data": "~2.18.0-beta.1",
     "ember-export-application-global": "^2.0.0",
     "ember-load-initializers": "^1.0.0",
     "ember-resolver": "^4.0.0",
-    "ember-source": "~3.0.0-beta.1",
+    "ember-source": "~2.18.0-beta.3",
     "ember-welcome-page": "^3.0.0",
     "eslint-plugin-ember": "^5.0.0",
     "loader.js": "^4.2.3"