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

test(ssr): add tests for @wire errors #4915

Merged
merged 3 commits into from
Nov 21, 2024
Merged

Conversation

nolanlawson
Copy link
Contributor

Details

Follow-up to #4910. This doesn't test all the @wire errors, but it's a start.

These are copied from the wire-decorator/throws-* tests in babel-plugin-component.

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.

@nolanlawson nolanlawson requested a review from a team as a code owner November 21, 2024 20:30
'expected.html': '',
'error.txt': 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.

I figure we might as well start testing compiler errors in engine-server. It's convenient for SSR tests since they effectively do double-duty as a compiler and runtime.

const message = err?.message?.match(/(LWC\d+[^\n]+)/)?.[1];
return {
'expected.html': '',
'error.txt': message ?? '',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'error.txt': message ?? '',
'error.txt': err?.message ?? '',

Unless @lwc/errors is weird, err.message doesn't include the stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

err.message does include the stack here because the error actually comes from Babel-via-Rollup.

Also if err?.message is nullish, then message will be nullish as well.

@nolanlawson nolanlawson merged commit 7e27944 into master Nov 21, 2024
11 checks passed
@nolanlawson nolanlawson deleted the nolan/wired-errors branch November 21, 2024 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants