Repository: ember-cli/ember-cli
Pull request #9436 (2021-01-26 22:11:47)

Enable Embroider test scenario for addons
Leverage [@embroider/test-setup](https://github.com/embroider-build/embroider/tree/master/packages/test-setup) to add both `embroider-safe` and `embroider-optimized` scenarios for addons test matrix.


Patch:
diff --git a/blueprints/addon/additional-dev-dependencies.json b/blueprints/addon/additional-dev-dependencies.json
index 0786ce7d3..9611d6b9b 100644
--- a/blueprints/addon/additional-dev-dependencies.json
+++ b/blueprints/addon/additional-dev-dependencies.json
@@ -1,5 +1,6 @@
 {
   "devDependencies": {
+    "@embroider/test-setup": "^0.36.0",
     "ember-disable-prototype-extensions": "^1.1.3",
     "ember-try": "^1.4.0",
     "ember-source-channel-url": "^3.0.0"
diff --git a/blueprints/addon/files/.travis.yml b/blueprints/addon/files/.travis.yml
index 4f9511e4b..09b764f44 100644
--- a/blueprints/addon/files/.travis.yml
+++ b/blueprints/addon/files/.travis.yml
@@ -58,6 +58,8 @@ jobs:
     - env: EMBER_TRY_SCENARIO=ember-canary
     - env: EMBER_TRY_SCENARIO=ember-default-with-jquery
     - env: EMBER_TRY_SCENARIO=ember-classic
+    - env: EMBER_TRY_SCENARIO=embroider-safe
+    - env: EMBER_TRY_SCENARIO=embroider-optimized
 <% if (yarn) { %>
 before_install:
   - curl -o- -L https://yarnpkg.com/install.sh | bash
diff --git a/blueprints/addon/files/addon-config/ember-try.js b/blueprints/addon/files/addon-config/ember-try.js
index 657373b20..ba37be916 100644
--- a/blueprints/addon/files/addon-config/ember-try.js
+++ b/blueprints/addon/files/addon-config/ember-try.js
@@ -1,6 +1,7 @@
 'use strict';
 
 const getChannelURL = require('ember-source-channel-url');
+const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');
 
 module.exports = async function () {
   return {
@@ -74,6 +75,8 @@ module.exports = async function () {
           },
         },
       },
+      embroiderSafe(),
+      embroiderOptimized(),
     ],
   };
 };
diff --git a/blueprints/addon/files/ember-cli-build.js b/blueprints/addon/files/ember-cli-build.js
index ba0649dc9..a778499b7 100644
--- a/blueprints/addon/files/ember-cli-build.js
+++ b/blueprints/addon/files/ember-cli-build.js
@@ -14,5 +14,6 @@ module.exports = function (defaults) {
     behave. You most likely want to be modifying `./index.js` or app's build file
   */
 
-  return app.toTree();
+  const { maybeEmbroider } = require('@embroider/test-setup');
+  return maybeEmbroider(app);
 };


Test patch:
diff --git a/tests/fixtures/addon/defaults/.travis.yml b/tests/fixtures/addon/defaults/.travis.yml
index 156fd25fa..b9b72cdba 100644
--- a/tests/fixtures/addon/defaults/.travis.yml
+++ b/tests/fixtures/addon/defaults/.travis.yml
@@ -54,6 +54,8 @@ jobs:
     - env: EMBER_TRY_SCENARIO=ember-canary
     - env: EMBER_TRY_SCENARIO=ember-default-with-jquery
     - env: EMBER_TRY_SCENARIO=ember-classic
+    - env: EMBER_TRY_SCENARIO=embroider-safe
+    - env: EMBER_TRY_SCENARIO=embroider-optimized
 
 script:
   - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
diff --git a/tests/fixtures/addon/defaults/config/ember-try.js b/tests/fixtures/addon/defaults/config/ember-try.js
index e59f91b33..2ab59e5b6 100644
--- a/tests/fixtures/addon/defaults/config/ember-try.js
+++ b/tests/fixtures/addon/defaults/config/ember-try.js
@@ -1,6 +1,7 @@
 'use strict';
 
 const getChannelURL = require('ember-source-channel-url');
+const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');
 
 module.exports = async function () {
   return {
@@ -73,6 +74,8 @@ module.exports = async function () {
           },
         },
       },
+      embroiderSafe(),
+      embroiderOptimized(),
     ],
   };
 };
diff --git a/tests/fixtures/addon/defaults/package.json b/tests/fixtures/addon/defaults/package.json
index e4c5c203e..78ebc0dcb 100644
--- a/tests/fixtures/addon/defaults/package.json
+++ b/tests/fixtures/addon/defaults/package.json
@@ -32,6 +32,7 @@
   "devDependencies": {
     "@ember/optional-features": "^2.0.0",
     "@ember/test-helpers": "^2.1.4",
+    "@embroider/test-setup": "^0.36.0",
     "@glimmer/component": "^1.0.3",
     "@glimmer/tracking": "^1.0.3",
     "babel-eslint": "^10.1.0",
diff --git a/tests/fixtures/addon/yarn/.travis.yml b/tests/fixtures/addon/yarn/.travis.yml
index 3a7ed03cd..592dc1247 100644
--- a/tests/fixtures/addon/yarn/.travis.yml
+++ b/tests/fixtures/addon/yarn/.travis.yml
@@ -53,6 +53,8 @@ jobs:
     - env: EMBER_TRY_SCENARIO=ember-canary
     - env: EMBER_TRY_SCENARIO=ember-default-with-jquery
     - env: EMBER_TRY_SCENARIO=ember-classic
+    - env: EMBER_TRY_SCENARIO=embroider-safe
+    - env: EMBER_TRY_SCENARIO=embroider-optimized
 
 before_install:
   - curl -o- -L https://yarnpkg.com/install.sh | bash
diff --git a/tests/fixtures/addon/yarn/config/ember-try.js b/tests/fixtures/addon/yarn/config/ember-try.js
index f14ac7f50..72f0ea604 100644
--- a/tests/fixtures/addon/yarn/config/ember-try.js
+++ b/tests/fixtures/addon/yarn/config/ember-try.js
@@ -1,6 +1,7 @@
 'use strict';
 
 const getChannelURL = require('ember-source-channel-url');
+const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');
 
 module.exports = async function () {
   return {
@@ -74,6 +75,8 @@ module.exports = async function () {
           },
         },
       },
+      embroiderSafe(),
+      embroiderOptimized(),
     ],
   };
 };
diff --git a/tests/fixtures/addon/yarn/package.json b/tests/fixtures/addon/yarn/package.json
index f6d9d8626..4e899b667 100644
--- a/tests/fixtures/addon/yarn/package.json
+++ b/tests/fixtures/addon/yarn/package.json
@@ -32,6 +32,7 @@
   "devDependencies": {
     "@ember/optional-features": "^2.0.0",
     "@ember/test-helpers": "^2.1.4",
+    "@embroider/test-setup": "^0.36.0",
     "@glimmer/component": "^1.0.3",
     "@glimmer/tracking": "^1.0.3",
     "babel-eslint": "^10.1.0",
diff --git a/tests/unit/blueprints/addon-test.js b/tests/unit/blueprints/addon-test.js
index c56cf7e96..e0129e9a0 100644
--- a/tests/unit/blueprints/addon-test.js
+++ b/tests/unit/blueprints/addon-test.js
@@ -180,6 +180,7 @@ describe('blueprint - addon', function () {
         delete json.devDependencies['eslint-plugin-node'];
         delete json.devDependencies['ember-try'];
         delete json.devDependencies['ember-source-channel-url'];
+        delete json.devDependencies['@embroider/test-setup'];
         expect(json.dependencies).to.deep.equal({ a: '1', b: '1' });
         expect(json.devDependencies).to.deep.equal({ a: '1', b: '1' });
       });