Repository: ember-cli/ember-cli
Pull request #7177 (2017-06-30 22:47:34)

verify npm/yarn logic in travis files
From https://github.com/ember-cli/ember-cli/pull/7169#issuecomment-312379050

Already found one bug in the files!

If this seems like too much overhead, please note I plan on building upon these tests with README checks in the next PR.


Patch:
diff --git a/blueprints/addon/files/.travis.yml b/blueprints/addon/files/.travis.yml
index e17139791..53d601d93 100644
--- a/blueprints/addon/files/.travis.yml
+++ b/blueprints/addon/files/.travis.yml
@@ -33,8 +33,7 @@ matrix:
   allow_failures:
     - env: EMBER_TRY_SCENARIO=ember-canary
 
-before_install:
-<% if (yarn) { %>
+before_install:<% if (yarn) { %>
   - curl -o- -L https://yarnpkg.com/install.sh | bash
   - export PATH=$HOME/.yarn/bin:$PATH
 
diff --git a/blueprints/app/files/.travis.yml b/blueprints/app/files/.travis.yml
index 74023ac72..7ac4a42df 100644
--- a/blueprints/app/files/.travis.yml
+++ b/blueprints/app/files/.travis.yml
@@ -16,8 +16,7 @@ cache:
   directories:
     - $HOME/.npm
 <% } %>
-before_install:
-<% if (yarn) { %>
+before_install:<% if (yarn) { %>
   - curl -o- -L https://yarnpkg.com/install.sh | bash
   - export PATH=$HOME/.yarn/bin:$PATH
 


Test patch:
diff --git a/tests/acceptance/new-test.js b/tests/acceptance/new-test.js
index 681a1fcff..3140f4249 100644
--- a/tests/acceptance/new-test.js
+++ b/tests/acceptance/new-test.js
@@ -363,4 +363,76 @@ describe('Acceptance: ember new', function() {
     expect(file('app/templates/application.hbs'))
       .to.contain("Welcome to Ember");
   }));
+
+  describe('verify fictures', function() {
+    it('app + npm', co.wrap(function *() {
+      yield ember([
+        'new',
+        'foo',
+        '--skip-npm',
+        '--skip-bower',
+        '--skip-git',
+      ]);
+
+      [
+        '.travis.yml',
+      ].forEach(filePath => {
+        expect(file(filePath))
+          .to.equal(file(path.join(__dirname, '../fixtures/app/npm', filePath)));
+      });
+    }));
+
+    it('app + yarn', co.wrap(function *() {
+      yield ember([
+        'new',
+        'foo',
+        '--skip-npm',
+        '--skip-bower',
+        '--skip-git',
+        '--yarn',
+      ]);
+
+      [
+        '.travis.yml',
+      ].forEach(filePath => {
+        expect(file(filePath))
+          .to.equal(file(path.join(__dirname, '../fixtures/app/yarn', filePath)));
+      });
+    }));
+
+    it('addon + npm', co.wrap(function *() {
+      yield ember([
+        'addon',
+        'foo',
+        '--skip-npm',
+        '--skip-bower',
+        '--skip-git',
+      ]);
+
+      [
+        '.travis.yml',
+      ].forEach(filePath => {
+        expect(file(filePath))
+          .to.equal(file(path.join(__dirname, '../fixtures/addon/npm', filePath)));
+      });
+    }));
+
+    it('addon + yarn', co.wrap(function *() {
+      yield ember([
+        'addon',
+        'foo',
+        '--skip-npm',
+        '--skip-bower',
+        '--skip-git',
+        '--yarn',
+      ]);
+
+      [
+        '.travis.yml',
+      ].forEach(filePath => {
+        expect(file(filePath))
+          .to.equal(file(path.join(__dirname, '../fixtures/addon/yarn', filePath)));
+      });
+    }));
+  });
 });
diff --git a/tests/fixtures/addon/npm/.travis.yml b/tests/fixtures/addon/npm/.travis.yml
new file mode 100644
index 000000000..0801ec37a
--- /dev/null
+++ b/tests/fixtures/addon/npm/.travis.yml
@@ -0,0 +1,40 @@
+---
+language: node_js
+node_js:
+  # we recommend testing addons with the same minimum supported node version as Ember CLI
+  # so that your addon works for all apps
+  - "4"
+
+sudo: false
+dist: trusty
+
+addons:
+  chrome: stable
+
+cache:
+  directories:
+    - $HOME/.npm
+
+env:
+  # we recommend new addons test the current and previous LTS
+  # as well as latest stable release (bonus points to beta/canary)
+  - EMBER_TRY_SCENARIO=ember-lts-2.8
+  - EMBER_TRY_SCENARIO=ember-lts-2.12
+  - EMBER_TRY_SCENARIO=ember-release
+  - EMBER_TRY_SCENARIO=ember-beta
+  - EMBER_TRY_SCENARIO=ember-canary
+  - EMBER_TRY_SCENARIO=ember-default
+
+matrix:
+  fast_finish: true
+  allow_failures:
+    - env: EMBER_TRY_SCENARIO=ember-canary
+
+before_install:
+  - npm config set spin false
+  - npm --version
+
+script:
+  # Usually, it's ok to finish the test scenario without reverting
+  #  to the addon's original dependency state, skipping "cleanup".
+  - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
diff --git a/tests/fixtures/addon/yarn/.travis.yml b/tests/fixtures/addon/yarn/.travis.yml
new file mode 100644
index 000000000..e1c2f1bfa
--- /dev/null
+++ b/tests/fixtures/addon/yarn/.travis.yml
@@ -0,0 +1,42 @@
+---
+language: node_js
+node_js:
+  # we recommend testing addons with the same minimum supported node version as Ember CLI
+  # so that your addon works for all apps
+  - "4"
+
+sudo: false
+dist: trusty
+
+addons:
+  chrome: stable
+
+cache:
+  yarn: true
+
+env:
+  # we recommend new addons test the current and previous LTS
+  # as well as latest stable release (bonus points to beta/canary)
+  - EMBER_TRY_SCENARIO=ember-lts-2.8
+  - EMBER_TRY_SCENARIO=ember-lts-2.12
+  - EMBER_TRY_SCENARIO=ember-release
+  - EMBER_TRY_SCENARIO=ember-beta
+  - EMBER_TRY_SCENARIO=ember-canary
+  - EMBER_TRY_SCENARIO=ember-default
+
+matrix:
+  fast_finish: true
+  allow_failures:
+    - env: EMBER_TRY_SCENARIO=ember-canary
+
+before_install:
+  - curl -o- -L https://yarnpkg.com/install.sh | bash
+  - export PATH=$HOME/.yarn/bin:$PATH
+
+install:
+  - yarn install --no-lockfile
+
+script:
+  # Usually, it's ok to finish the test scenario without reverting
+  #  to the addon's original dependency state, skipping "cleanup".
+  - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
diff --git a/tests/fixtures/app/npm/.travis.yml b/tests/fixtures/app/npm/.travis.yml
new file mode 100644
index 000000000..35340c417
--- /dev/null
+++ b/tests/fixtures/app/npm/.travis.yml
@@ -0,0 +1,17 @@
+---
+language: node_js
+node_js:
+  - "6"
+
+sudo: false
+dist: trusty
+
+addons:
+  chrome: stable
+
+cache:
+  directories:
+    - $HOME/.npm
+
+before_install:
+  - npm config set spin false
diff --git a/tests/fixtures/app/yarn/.travis.yml b/tests/fixtures/app/yarn/.travis.yml
new file mode 100644
index 000000000..5e7ac04f4
--- /dev/null
+++ b/tests/fixtures/app/yarn/.travis.yml
@@ -0,0 +1,23 @@
+---
+language: node_js
+node_js:
+  - "6"
+
+sudo: false
+dist: trusty
+
+addons:
+  chrome: stable
+
+cache:
+  yarn: true
+
+before_install:
+  - curl -o- -L https://yarnpkg.com/install.sh | bash
+  - export PATH=$HOME/.yarn/bin:$PATH
+
+install:
+  - yarn install
+
+script:
+  - yarn test