Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
excludedFiles: [
'app/**',
'addon/**',
'test/fixtures/**',
'tests/dummy/app/**'
],
parserOptions: {
Expand Down
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
language: node_js
node_js:
- "4"
- "6"
- "8"

dist: trusty
sudo: false
dist: trusty

addons:
chrome: stable
Expand All @@ -17,13 +17,13 @@ stages:
- lint
- test
- deploy

jobs:
fail_fast: true

include:
- stage: lint
script: yarn lint:js
script: npm run-script lint:js
- stage: deploy
if: tag IS present
node_js: "6"
Expand All @@ -46,4 +46,4 @@ install:
- yarn install --no-lockfile --non-interactive

script:
- yarn node-test
- npm run-script node-test
1 change: 0 additions & 1 deletion app/utils/my-covered-util.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/utils/my-uncovered-util.js

This file was deleted.

7 changes: 0 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ module.exports = {
});
},

treeFor() {
// Only include test fixtures when testing the addon.
if (this._parentName() === this.name) {
return this._super.treeFor.apply(this, arguments);
}
},

// Custom Methods

/**
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"chai": "^4.1.2",
"chai-files": "^1.2.0",
"ember-cli": "~3.0.0-beta.2",
"ember-cli-addon-tests": "^0.11.0",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.2.1",
"ember-cli-htmlbars": "^2.0.1",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/my-addon/app/utils/my-covered-util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '../../addon/utils/my-covered-util';
2 changes: 2 additions & 0 deletions test/fixtures/my-addon/app/utils/my-uncovered-util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from '../../addon/utils/my-uncovered-util';

43 changes: 43 additions & 0 deletions test/fixtures/my-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
extends: [
'eslint:recommended'
],
env: {
browser: true
},
rules: {
},
overrides: [
// node files
{
files: [
'index.js',
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'lib/**',
'test/**',
'tests/dummy/config/**/*.js'
],
excludedFiles: [
'app/**',
'addon/**',
'test/fixtures/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
}
}
]
};
3 changes: 3 additions & 0 deletions test/fixtures/my-app/app/utils/my-covered-util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function myCoveredUtil() {
return true;
}
3 changes: 3 additions & 0 deletions test/fixtures/my-app/app/utils/my-uncovered-util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function myUncoveredUtil() {
return true;
}
24 changes: 24 additions & 0 deletions test/fixtures/my-app/testem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'Chrome'
],
launch_in_dev: [
'Chrome'
],
browser_args: {
Chrome: {
mode: 'ci',
args: [
// --no-sandbox is needed when running Chrome inside a container
process.env.TRAVIS ? '--no-sandbox' : null,

'--disable-gpu',
'--headless',
'--remote-debugging-port=0',
'--window-size=1440,900'
].filter(Boolean)
}
}
};
Empty file.
10 changes: 10 additions & 0 deletions test/fixtures/my-app/tests/unit/utils/my-covered-util-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import myCoveredUtil from 'my-app/utils/my-covered-util';
import { module, test } from 'qunit';

module('Unit | Utility | my covered util');

// Replace this with your real tests.
test('it works', function(assert) {
let result = myCoveredUtil();
assert.ok(result);
});
33 changes: 0 additions & 33 deletions test/helpers/run-command.js

This file was deleted.

111 changes: 111 additions & 0 deletions test/integration/app-coverage-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
'use strict';

var fs = require('fs-extra');
var RSVP = require('rsvp');
var rimraf = RSVP.denodeify(require('rimraf'));
var chai = require('chai');
var expect = chai.expect;
var chaiFiles = require('chai-files');
var dir = chaiFiles.dir;
var file = chaiFiles.file;

const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp;

chai.use(chaiFiles);

let app;

describe('app coverage generation', function() {
this.timeout(10000000);
beforeEach(function() {
app = new AddonTestApp();
return app.create('my-app', {
emberVersion: '2.16.0'
}).then(() => {
app.editPackageJSON(pkg => {
pkg.devDependencies['ember-exam'] = '0.7.0';
});
return app.run('npm', 'install').then(() => {
return rimraf(`${app.path}/coverage*`);
});
});
});

afterEach(function() {
return RSVP.all([
rimraf(`${app.path}/config/coverage.js`)
]);
});

it('runs coverage when env var is set', function() {
expect(dir(`${app.path}/coverage`)).to.not.exist;
process.env.COVERAGE = true;
return app.run('ember', 'test').then(function() {
expect(file(`${app.path}/coverage/lcov-report/index.html`)).to.not.be.empty;
expect(file(`${app.path}/coverage/index.html`)).to.not.be.empty;
var summary = fs.readJSONSync(`${app.path}/coverage/coverage-summary.json`);
expect(summary.total.lines.pct).to.equal(83.33);
});
});

it('does not run coverage when env var is NOT set', function() {
expect(dir(`${app.path}/coverage`)).to.not.exist;
process.env.COVERAGE = false;
return app.run('ember', 'test').then(function() {
expect(dir(`${app.path}/coverage`)).to.not.exist;
});
});

it('excludes files when the configuration is set', function() {
fs.copySync('tests/dummy/config/coverage-excludes.js', `${app.path}/config/coverage.js`);
process.env.COVERAGE = true;
return app.run('ember', 'test').then(function() {
expect(file(`${app.path}/coverage/lcov-report/index.html`)).to.not.be.empty;
expect(file(`${app.path}/coverage/index.html`)).to.not.be.empty;
var summary = fs.readJSONSync(`${app.path}/coverage/coverage-summary.json`);
expect(summary.total.lines.pct).to.equal(100);
});
});

it('uses parallel configuration and merges coverage when merge-coverage command is issued', function() {
expect(dir(`${app.path}/coverage`)).to.not.exist;
fs.copySync('tests/dummy/config/coverage-parallel.js', `${app.path}/config/coverage.js`);
process.env.COVERAGE = true;
return app.run('ember', 'exam', '--split=2', '--parallel=true').then(function() {
expect(dir(`${app.path}/coverage`)).to.not.exist;
return app.run('ember', 'coverage-merge');
}).then(function() {
expect(file(`${app.path}/coverage/lcov-report/index.html`)).to.not.be.empty;
expect(file(`${app.path}/coverage/index.html`)).to.not.be.empty;
var summary = fs.readJSONSync(`${app.path}/coverage/coverage-summary.json`);
expect(summary.total.lines.pct).to.equal(83.33);
});
});

it('uses nested coverageFolder and parallel configuration and run merge-coverage', function() {
var coverageFolder = `${app.path}/coverage/abc/easy-as/123`;

expect(dir(coverageFolder)).to.not.exist;
fs.copySync('tests/dummy/config/coverage-nested-folder.js', `${app.path}/config/coverage.js`);
process.env.COVERAGE = true;
return app.run('ember', 'exam', '--split=2', '--parallel=true').then(function() {
expect(dir(coverageFolder)).to.not.exist;
return app.run('ember', 'coverage-merge');
}).then(function() {
expect(file(`${coverageFolder}/lcov-report/index.html`)).to.not.be.empty;
expect(file(`${coverageFolder}/index.html`)).to.not.be.empty;
var summary = fs.readJSONSync(`${coverageFolder}/coverage-summary.json`);
expect(summary.total.lines.pct).to.equal(83.33);
});
});

it('runs coverage when a module has an import error', function() {
expect(dir(`${app.path}/coverage`)).to.not.exist;
fs.copySync('test/helpers/error-module.js', `${app.path}/app/error-module.js`);
process.env.COVERAGE = true;
return app.run('ember', 'test').then(function() {
expect(dir(`${app.path}/coverage`)).to.exist;
return rimraf(`${app.path}/app/error-module.js`);
});
});
});
Loading