Skip to content

Commit

Permalink
2.0.3 (#129) [ci skip]
Browse files Browse the repository at this point in the history
* fix configs

* remove empty test

* [ci skip] version bump
  • Loading branch information
adamgruber authored Feb 9, 2017
1 parent dfc549f commit c08b1a4
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#Changelog

###2.0.3
- Fixed [#126](https://github.com/adamgruber/mochawesome/issues/126)
- Fix default options handling
- Add `enableCode` option to be consistent with mochawesome-report-generator options
- Deprecate `enableTestCode` option
- Add `dev` option for testing

###2.0.2
- Fixed [#111](https://github.com/adamgruber/mochawesome/issues/111)

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ Option Name | Type | Default | Description
`reportPageTitle` | string | mochawesome-report | Browser title
`inlineAssets` | boolean | false | Inline report assets (scripts, styles)
`enableCharts` | boolean | true | Display Suite charts
`enableTestCode` | boolean | true | Display test code
`enableCode` | boolean | true | Display test code
`enableTestCode` | boolean | true | Same as `enableCode` *deprecated*
`autoOpen` | boolean | false | Open the report after running tests
`quiet` | boolean | false | Silence console messages
Expand Down
16 changes: 12 additions & 4 deletions dist/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ var baseConfig = {
inlineAssets: false,
autoOpen: false,
enableCharts: true,
enableTestCode: true,
quiet: false
enableCode: true,
quiet: false,
dev: false
};

function _getOption(optToGet, options, isBool) {
Expand All @@ -32,21 +33,28 @@ function _getOption(optToGet, options, isBool) {
if (typeof process.env[envVar] !== 'undefined') {
return isBool ? process.env[envVar] === 'true' : process.env[envVar];
}
return isBool ? baseConfig[optToGet] === 'true' : baseConfig[optToGet];
return baseConfig[optToGet];
}

module.exports = function (opts) {
var options = {};

// Added for compatibility. enableTestCode option is deprecated as of 2.0.3
if (Object.hasOwnProperty.call(opts, 'enableTestCode')) {
opts.enableCode = opts.enableTestCode;
delete opts.enableTestCode;
}

options.reportFilename = _getOption('reportFilename', opts);
options.reportDir = path.resolve(_getOption('reportDir', opts));
options.reportTitle = _getOption('reportTitle', opts);
options.reportPageTitle = _getOption('reportPageTitle', opts);
options.inlineAssets = _getOption('inlineAssets', opts, true);
options.autoOpen = _getOption('autoOpen', opts, true);
options.enableCharts = _getOption('enableCharts', opts, true);
options.enableTestCode = _getOption('enableTestCode', opts, true);
options.enableCode = _getOption('enableCode', opts, true);
options.quiet = _getOption('quiet', opts, true);
options.dev = _getOption('dev', opts, true);

// Report Files
options.reportJsonFile = path.join(options.reportDir, options.reportFilename + '.json');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mochawesome",
"version": "2.0.2",
"version": "2.0.3",
"description": "A Gorgeous HTML/CSS Reporter for Mocha.js",
"scripts": {
"lint": "eslint src test",
Expand Down
18 changes: 12 additions & 6 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const baseConfig = {
inlineAssets: false,
autoOpen: false,
enableCharts: true,
enableTestCode: true,
quiet: false
enableCode: true,
quiet: false,
dev: false
};

function _getOption(optToGet, options, isBool) {
Expand All @@ -28,23 +29,28 @@ function _getOption(optToGet, options, isBool) {
? process.env[envVar] === 'true'
: process.env[envVar];
}
return isBool
? baseConfig[optToGet] === 'true'
: baseConfig[optToGet];
return baseConfig[optToGet];
}

module.exports = function (opts) {
const options = {};

// Added for compatibility. enableTestCode option is deprecated as of 2.0.3
if (Object.hasOwnProperty.call(opts, 'enableTestCode')) {
opts.enableCode = opts.enableTestCode;
delete opts.enableTestCode;
}

options.reportFilename = _getOption('reportFilename', opts);
options.reportDir = path.resolve(_getOption('reportDir', opts));
options.reportTitle = _getOption('reportTitle', opts);
options.reportPageTitle = _getOption('reportPageTitle', opts);
options.inlineAssets = _getOption('inlineAssets', opts, true);
options.autoOpen = _getOption('autoOpen', opts, true);
options.enableCharts = _getOption('enableCharts', opts, true);
options.enableTestCode = _getOption('enableTestCode', opts, true);
options.enableCode = _getOption('enableCode', opts, true);
options.quiet = _getOption('quiet', opts, true);
options.dev = _getOption('dev', opts, true);

// Report Files
options.reportJsonFile = path.join(options.reportDir, `${options.reportFilename}.json`);
Expand Down
19 changes: 5 additions & 14 deletions test/reporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ describe('mochawesome reporter', () => {
reportFilename: 'testReportFilename',
reportTitle: 'testReportTitle',
inlineAssets: 'true',
autoOpen: true,
quiet: true
enableCharts: 'true',
enableTestCode: false,
autoOpen: true
}
});

Expand All @@ -171,8 +172,9 @@ describe('mochawesome reporter', () => {
mochaReporter.config.reportFilename.should.equal('testReportFilename');
mochaReporter.config.reportTitle.should.equal('testReportTitle');
mochaReporter.config.inlineAssets.should.equal(true);
mochaReporter.config.enableCharts.should.equal(true);
mochaReporter.config.enableCode.should.equal(false);
mochaReporter.config.autoOpen.should.equal(true);
mochaReporter.config.quiet.should.equal(true);
done();
});
});
Expand Down Expand Up @@ -209,17 +211,6 @@ describe('mochawesome reporter', () => {
});
});

it('should log an error when report creation fails', done => {
writeFileStub.yields(null, {});
reportStub.returns(Promise.reject({ message: 'report creation failed' }));
const test = makeTest('test', () => {});
subSuite.addTest(test);

runner.run(failureCount => {
mochaReporter.done(failureCount, done);
});
});

it('should not log when quiet option is true', done => {
reportStub.returns(Promise.resolve({}));
writeFileStub.yields(null, {});
Expand Down

0 comments on commit c08b1a4

Please sign in to comment.