Skip to content

make watch plugin initialization errors look nice#8422

Merged
jeysal merged 7 commits intojestjs:masterfrom
jeysal:watch-plugin-errors
May 7, 2019
Merged

make watch plugin initialization errors look nice#8422
jeysal merged 7 commits intojestjs:masterfrom
jeysal:watch-plugin-errors

Conversation

@jeysal
Copy link
Copy Markdown
Collaborator

@jeysal jeysal commented May 5, 2019

Summary

Follow up to jest-community/jest-watch-typeahead#29

image

Any idea how we could get rid of the outer stack trace and / or "Test suite failed to run"? In the current state it IMO looks worse than just the plain error. @SimenB
Edit: fixed outer stack trace, updated screenshot

Test plan

Added snapshot test.
Manual test -> see screenshot

@SimenB
Copy link
Copy Markdown
Member

SimenB commented May 5, 2019

Any idea how we could get rid of the outer stack trace and / or "Test suite failed to run"?

const e = new Error(
  `Failed to initialize watch plugin '${
    pluginWithConfig.path
  }':\n\n${formatExecError(err, contexts[0].config, {
    noStackTrace: false,
  })}`,
);

// or `delete` it
e.stack = '';

return Promise.reject(e);

Does that work?

I like the "Test suite failed to run" text, just getting rid of the outer stack trace should make it nice and clean 🙂

@jeysal
Copy link
Copy Markdown
Collaborator Author

jeysal commented May 5, 2019

jest-cli accesses error.stack for some reason, that's why it didn't work when I tried (just printed undefined etc and I assumed it was coming from Node). I changed it, let's see if some e2e test complains about this.

@jeysal
Copy link
Copy Markdown
Collaborator Author

jeysal commented May 5, 2019

Ah, the good old absolute path on CI. Well, I'll take care of that tomorrow...

Comment thread packages/jest-cli/src/cli/index.ts Outdated
@jeysal jeysal requested review from SimenB and thymikee May 6, 2019 09:02
Comment thread packages/jest-core/src/__tests__/__snapshots__/watch.test.js.snap Outdated
Comment thread packages/jest-cli/src/cli/index.ts Outdated
Comment thread packages/jest-core/src/watch.ts Outdated
Comment thread packages/jest-core/src/watch.ts Outdated
@jeysal jeysal requested a review from SimenB May 6, 2019 22:18
Comment thread packages/jest-core/src/watch.ts Outdated
const errorWithContext = new Error(
`Failed to initialize watch plugin "${chalk.bold(
path.posix.relative(process.cwd(), pluginWithConfig.path),
path.relative(process.cwd(), pluginWithConfig.path),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pass it through slash?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll try that 👍

Copy link
Copy Markdown
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.

CI is unhappy, but this lgtm. Really nice!

@github-actions
Copy link
Copy Markdown

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 11, 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.

4 participants