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

include error message for preset json #4766

Merged
merged 3 commits into from
Oct 26, 2017

Conversation

xjlim
Copy link
Contributor

@xjlim xjlim commented Oct 26, 2017

Fix #4755

@@ -64,6 +64,11 @@ const setupPreset = (
// $FlowFixMe
preset = (require(presetModule): InitialOptions);
} catch (error) {
if (error instanceof SyntaxError) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather flip it.

if (error.code === 'MODULE_NOT_FOUND') {
  throw createConfigError(`  Preset ${chalk.bold(presetPath)} not found.`);
}

throw createConfigError(
  `  Unable to load preset ${chalk.bold(presetPath)}:\n  ${error.message}`,
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimenB I am getting a different error for that (AssertionError for the actual require), the error code will only be shown in test (MODULE_NOT_FOUND from jest-resolve).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting. Thanks for checking!

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a test.

Can you also update the changelog?

@cpojer cpojer merged commit 165efcd into jestjs:master Oct 26, 2017
@cpojer
Copy link
Member

cpojer commented Oct 26, 2017

Nice! Thank you.

@niieani
Copy link
Contributor

niieani commented Oct 27, 2017

Awesome! 💛 Thank you @xjlim!

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unhelpful error message when jest is run with a preset containing a parse error
5 participants