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

Empty stack for ValidateError #3587

Merged
merged 2 commits into from
May 17, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ Object {
`;

exports[`Custom Reporters Integration invalid format for adding reporters 1`] = `
"● Reporter Validation Error:
"● Reporter Validation Error:

Unexpected value for Path at index 0 of reporter at index 0
Expected:
string
Got:
number
Reporter configuration:
Unexpected value for Path at index 0 of reporter at index 0
Expected:
string
Got:
number
Reporter configuration:
[
3243242
]
Expand Down
22 changes: 11 additions & 11 deletions packages/jest-config/src/reporterValidationErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {getType} = require('jest-matcher-utils');
const {DOCUMENTATION_NOTE, BULLET} = require('./utils');

const validReporterTypes = ['array', 'string'];
const ERROR = `${BULLET} Reporter Validation Error`;
const ERROR = `${BULLET}Reporter Validation Error`;

/**
* Reporter Vaidation Error is thrown if the given arguments
Expand All @@ -31,10 +31,10 @@ function createReporterError(
reporterValue: Array<ReporterConfig> | string,
): ValidationError {
const errorMessage =
`Reporter at index ${reporterIndex} must be of type:\n` +
` ${chalk.bold.green(validReporterTypes.join(' or '))}\n` +
` but instead received:\n` +
` ${chalk.bold.red(getType(reporterValue))}`;
` Reporter at index ${reporterIndex} must be of type:\n` +
` ${chalk.bold.green(validReporterTypes.join(' or '))}\n` +
` but instead received:\n` +
` ${chalk.bold.red(getType(reporterValue))}`;

return new ValidationError(ERROR, errorMessage, DOCUMENTATION_NOTE);
}
Expand All @@ -48,13 +48,13 @@ function createArrayReporterError(
valueName: string,
): ValidationError {
const errorMessage =
`Unexpected value for ${valueName} ` +
` Unexpected value for ${valueName} ` +
`at index ${valueIndex} of reporter at index ${reporterIndex}\n` +
' Expected:\n' +
` ${chalk.bold.red(expectedType)}\n` +
' Got:\n' +
` ${chalk.bold.green(getType(value))}\n` +
` Reporter configuration:\n` +
' Expected:\n' +
` ${chalk.bold.red(expectedType)}\n` +
' Got:\n' +
` ${chalk.bold.green(getType(value))}\n` +
` Reporter configuration:\n` +
` ${chalk.bold.green(JSON.stringify(arrayReporter, null, 2)
.split('\n')
.join('\n '))}`;
Expand Down
1 change: 1 addition & 0 deletions packages/jest-validate/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ValidationError extends Error {
super();
comment = comment ? '\n\n' + comment : '\n';
this.name = '';
this.stack = '';
this.message = chalk.red(chalk.bold(name) + ':\n\n' + message + comment);
Error.captureStackTrace(this, () => {});
}
Expand Down