Skip to content

fix(vue): accounts for undefined options when formatting component name #5254

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

Merged
merged 2 commits into from
Jun 14, 2022

Conversation

Arinono
Copy link
Contributor

@Arinono Arinono commented Jun 13, 2022

Issue

Fixes #5204

Implementation details

Returns the ANONYMOUS_COMPONENT_NAME early if vm.$options is not defined.


Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

Arinono added 2 commits June 13, 2022 11:53
When formatting the component name, options can be undefined.
When it is, we return the ANONYMOUS_COMPONENT_NAME early

Fixes getsentry#5204
@Arinono Arinono force-pushed the fix/5204/vue-options-undefined branch from ee0acd6 to 6139907 Compare June 13, 2022 09:53
Comment on lines +24 to +35
describe('and when the $options is not defined', () => {
it('returns the anonymous component name', () => {
// arrange
vm.$options = undefined;

// act
const formattedName = formatComponentName(vm);

// assert
expect(formattedName).toEqual('<Anonymous>');
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main test I added.
Commenting the fix will make this test fail.
The rest is refactor (and the right-side ternary on name line 50 which was not covered).

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@AbhiPrasad AbhiPrasad enabled auto-merge (squash) June 14, 2022 15:24
@AbhiPrasad AbhiPrasad merged commit 0d07854 into getsentry:master Jun 14, 2022
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.

$options missing in vm when catching exceptions in Vue components
2 participants