Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new cmdline option to denote implicit returns #3758

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/cli/run-option-metadata.js
Expand Up @@ -35,6 +35,7 @@ exports.types = {
'forbid-pending',
'full-trace',
'growl',
'implicit-returns',
'inline-diffs',
'interfaces',
'invert',
Expand Down
4 changes: 4 additions & 0 deletions lib/cli/run.js
Expand Up @@ -143,6 +143,10 @@ exports.builder = yargs =>
description: 'Enable Growl notifications',
group: GROUPS.OUTPUT
},
'implicit-returns': {
description: 'Denote source language uses implicit returns',
group: GROUPS.RULES
},
'inline-diffs': {
description:
'Display actual/expected differences inline within each string',
Expand Down
15 changes: 9 additions & 6 deletions lib/interfaces/common.js
@@ -1,9 +1,11 @@
'use strict';

var util = require('util');
var Suite = require('../suite');
var utils = require('../utils');
var errors = require('../errors');
var createMissingArgumentError = errors.createMissingArgumentError;
var dQuote = utils.dQuote;

/**
* Functions common to more than one interface.
Expand Down Expand Up @@ -139,13 +141,14 @@ module.exports = function(suites, context, mocha) {
}
if (typeof opts.fn === 'function') {
var result = opts.fn.call(suite);
if (typeof result !== 'undefined') {
if (typeof result !== 'undefined' && !mocha.options.implicitReturns) {
utils.deprecate(
'Suites ignore return values. Suite "' +
suite.fullTitle() +
'" in ' +
suite.file +
' returned a value; this may be a bug in your test code'
util.format(
'Suites ignore return values. Suite %s in %s returned a value; ' +
'this may be a bug in your test code',
dQuote(suite.fullTitle()),
dQuote(suite.file)
)
);
}
suites.shift();
Expand Down
1 change: 1 addition & 0 deletions lib/mocha.js
Expand Up @@ -81,6 +81,7 @@ exports.Test = require('./test');
* @param {boolean} [options.growl] - Enable desktop notifications?
* @param {boolean} [options.hideDiff] - Suppress diffs from failures?
* @param {boolean} [options.ignoreLeaks] - Ignore global leaks?
* @param {boolean} [options.implicitReturns] - Language uses implicit returns?
* @param {boolean} [options.invert] - Invert test filter matches?
* @param {boolean} [options.noHighlighting] - Disable syntax highlighting?
* @param {string} [options.reporter] - Reporter name.
Expand Down