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

make watch plugin initialization errors look nice #8422

Merged
merged 7 commits into from May 7, 2019

Conversation

jeysal
Copy link
Contributor

@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
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
Contributor 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
Contributor Author

jeysal commented May 5, 2019

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

@jeysal jeysal requested review from SimenB and thymikee May 6, 2019 09:02
packages/jest-cli/src/cli/index.ts Outdated Show resolved Hide resolved
packages/jest-core/src/watch.ts Outdated Show resolved Hide resolved
packages/jest-core/src/watch.ts Outdated Show resolved Hide resolved
@jeysal jeysal requested a review from SimenB May 6, 2019 22:18
@@ -183,7 +183,7 @@ export default function watch(
} catch (error) {
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
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
Contributor 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
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

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.

None yet

4 participants