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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ When running with `parallel` set to true, the final reports can be merged by usi

## Configuration

Configuration is optional. It should be put in a file at `config/coverage.js`.
Configuration is optional. It should be put in a file at `config/coverage.js` (`configPath` configuration in package.json is honored)

#### Options

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module.exports = {

testemMiddleware: function(app) {
if (!this._isCoverageEnabled()) { return; }
attachMiddleware(app, { root: this.project.root, ui: this.ui });
attachMiddleware(app, { configPath: this.project.configPath(), root: this.project.root });
},

// Custom Methods
Expand Down Expand Up @@ -204,7 +204,7 @@ module.exports = {
* @returns {Configuration} project configuration
*/
_getConfig: function() {
return config(this.project.root);
return config(this.project.configPath());
},

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/attach-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function(app, options) {
bodyParser.json({ limit: '50mb' }),
function(req, res) {
var collector = new Istanbul.Collector();
var _config = config(options.root);
var _config = config(options.configPath);

if (_config.parallel) {
_config.coverageFolder = _config.coverageFolder + '_' + crypto.randomBytes(4).toString('hex');
Expand Down
7 changes: 4 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ var path = require('path');
/**
* Get configuration for a project, falling back to default configuration if
* project does not provide a configuration of its own
* @param {String} root - root path of project
* @param {String} configPath - The path for the configuration of the project
* @returns {Configuration} configuration to use for project
*/
function config(root) {
var configFile = path.join(root, 'config', 'coverage.js');
function config(configPath) {
var configDirName = path.dirname(configPath);
var configFile = path.resolve(path.join(configDirName, 'coverage.js'));
var defaultConfig = getDefaultConfig();

if (fs.existsSync(configFile)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/coverage-merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ module.exports = {
* @returns {Configuration} project configuration
*/
_getConfig: function () {
return config(this.project.root);
return config(this.project.configPath());
}
};
4 changes: 2 additions & 2 deletions test/integration/coverage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('`ember test`', function() {
});

afterEach(function() {
return remove('config/coverage.js');
return remove('tests/dummy/config/coverage.js');
});

it('runs coverage when env var is set', function() {
Expand All @@ -43,7 +43,7 @@ describe('`ember test`', function() {
it('uses parallel configuration and merges coverage when merge-coverage command is issued', function() {
this.timeout(100000);
expect(dir('coverage')).to.not.exist;
fs.copySync('config/coverage-parallel.js', 'config/coverage.js');
fs.copySync('tests/dummy/config/coverage-parallel.js', 'tests/dummy/config/coverage.js');
return runCommand('ember', ['exam', '--split=2', '--parallel=true'], {env: {COVERAGE: true}}).then(function() {
expect(dir('coverage')).to.not.exist;
return runCommand('ember', ['coverage-merge']);
Expand Down
3 changes: 2 additions & 1 deletion test/unit/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ describe('index.js', function() {
};

Index.project = {
root: '/path/to/foo-bar'
root: '/path/to/foo-bar',
configPath: sinon.stub().returns('tests/dummy/config/environment.js')
};
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*jshint node:true*/
'use strict';

module.exports = {
parallel: true
Expand Down