Repository: ember-cli/ember-cli
Pull request #8399 (2019-02-03 20:48:55)

[INTERNAL] Improve jQuery deprecation message
* As discussed with @rwjblue, this makes the existing deprecation message more specific, stating explicitly that  the jQuery integration per se is deprecated and will be removed from Ember itself
* added tests


Patch:
diff --git a/lib/broccoli/ember-app.js b/lib/broccoli/ember-app.js
index a66f8e2f1..2a5e4c1de 100644
--- a/lib/broccoli/ember-app.js
+++ b/lib/broccoli/ember-app.js
@@ -489,7 +489,11 @@ class EmberApp {
       if (optionFeatures && !optionFeatures.isFeatureEnabled('jquery-integration')) {
         return;
       }
-      this.project.ui.writeDeprecateLine('Ember will stop including jQuery by default in an upcoming version. If you wish keep using jQuery in your application explicitly add `@ember/jquery` to your package.json');
+      this.project.ui.writeDeprecateLine(
+        'The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0. You can either' +
+        ' opt-out of using jQuery, or install the `@ember/jquery` addon to provide the jQuery integration. Please' +
+        ' consult the deprecation guide for further details: https://emberjs.com/deprecations/v3.x#toc_jquery-apis'
+      );
       jqueryPath = ember.paths.jquery;
     } else {
       jqueryPath = `${this.bowerDirectory}/jquery/dist/jquery.js`;


Test patch:
diff --git a/tests/unit/broccoli/ember-app-test.js b/tests/unit/broccoli/ember-app-test.js
index 4b9f5d2f3..19f688e1b 100644
--- a/tests/unit/broccoli/ember-app-test.js
+++ b/tests/unit/broccoli/ember-app-test.js
@@ -468,6 +468,10 @@ describe('EmberApp', function() {
         'bar': 'bar',
       });
 
+      app = new EmberApp({
+        project,
+      });
+
       app.trees.public = input.path();
       app.addonTreesFor = function() {
         return [
@@ -511,6 +515,10 @@ describe('EmberApp', function() {
         'bar': 'bar',
       });
 
+      app = new EmberApp({
+        project,
+      });
+
       app.trees.public = input.path();
       app.addonTreesFor = function() {
         return [
@@ -1644,27 +1652,76 @@ describe('EmberApp', function() {
     });
   });
 
-  it('shows ember-cli-shims deprecation', function() {
-    let root = path.resolve(__dirname, '../../fixtures/app/npm');
-    let project = setupProject(root);
-    project.require = function() {
-      return {
-        version: '5.0.0',
+
+  describe('deprecations', function() {
+    it('shows ember-cli-shims deprecation', function() {
+      let root = path.resolve(__dirname, '../../fixtures/app/npm');
+      let project = setupProject(root);
+      project.require = function() {
+        return {
+          version: '5.0.0',
+        };
+      };
+      project.initializeAddons = function() {
+        this.addons = [
+          {
+            name: 'ember-cli-babel',
+            pkg: { version: '5.0.0' },
+          },
+        ];
       };
-    };
-    project.initializeAddons = function() {
-      this.addons = [
-        {
-          name: 'ember-cli-babel',
-          pkg: { version: '5.0.0' },
-        },
-      ];
-    };
 
-    app = new EmberApp({
-      project,
+      app = new EmberApp({
+        project,
+      });
+
+      expect(project.ui.output).to.contain("You have not included `ember-cli-shims` in your project's `bower.json` or `package.json`.");
     });
 
-    expect(project.ui.output).to.contain("You have not included `ember-cli-shims` in your project's `bower.json` or `package.json`.");
+    describe('jQuery integration', function() {
+      it('shows deprecation', function() {
+        project.initializeAddons = function() {
+          this.addons = [
+            { name: 'ember-source', paths: {} },
+          ];
+        };
+        app = new EmberApp({ project });
+
+        expect(project.ui.output).to.contain(
+          'The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0'
+        );
+      });
+
+      it('does not show deprecation if the app has `@ember/jquery` installed', function() {
+        project.initializeAddons = function() {
+          this.addons = [
+            { name: 'ember-source', paths: {} },
+            { name: '@ember/jquery' },
+          ];
+        };
+        app = new EmberApp({ project });
+        expect(project.ui.output).to.not.contain(
+          'The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0'
+        );
+      });
+
+      it('does not show deprecation if the app has `@ember/optional-features` with the `jquery-integration` FF turned off', function() {
+        project.initializeAddons = function() {
+          this.addons = [
+            { name: 'ember-source', paths: {} },
+            {
+              name: '@ember/optional-features',
+              isFeatureEnabled() {
+                return false;
+              },
+            },
+          ];
+        };
+        app = new EmberApp({ project, vendorFiles: { 'ember-testing.js': null } });
+        expect(project.ui.output).to.not.contain(
+          'The integration of jQuery into Ember has been deprecated and will be removed with Ember 4.0'
+        );
+      });
+    });
   });
 });