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

BSlotComponent crashed with "TypeError: Cannot read properties of undefined (reading 'default')" #44

Closed
kikuomax opened this issue Aug 25, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@kikuomax
Copy link
Collaborator

kikuomax commented Aug 25, 2023

Overview of the problem

Buefy version: buefy-next (67ecf3a)
Vuejs version: 3.3.4
OS/Browser: macOS/@vue/test-utils

Description

A <b-slot-component> crashed with the following error if the underlying component has no slot:

TypeError: Cannot read properties of undefined (reading 'default')

Steps to reproduce

I encountered this while working on unit tests of SlotComponent:

I have not confirmed if this can happen on a browser. A user should not directly use SlotComponent because it is not exported from Buefy.

Expected behavior

No error is thrown.

Actual behavior

It threw an error.

@kikuomax kikuomax self-assigned this Aug 29, 2023
@kikuomax kikuomax added the bug Something isn't working label Aug 29, 2023
kikuomax added a commit to kikuomax/buefy that referenced this issue Aug 29, 2023
- Fixes the issue that `BSlotComponent` crashed with the following error
  if the underlying component has no slot: "TypeError: Cannot read
  properties of undefined (reading 'default')". Makes sure that the
  underlying component has slot before accessing it.

issue ntohq#44
kikuomax added a commit that referenced this issue Aug 29, 2023
- Updates the unit tests of `SlotComponent` so that they can work with
  `@vue/test-utils` V2, Vue 3, and breaking changes:
    - Calls `Component.vm.$forceUpdate` to emit the default "updated"
      lifecycle event instead of using `$emit`, because Vue 3
      differently handles lifecycle events from ordinary events.
    - Introduces a new test case "refresh on default event with existing
      handler" to test if `updated` hook of the underlying component is
      also invoked.
    - Introduces new test cases "refresh on custom event with existing
      handler (xyz)" to test if the event handler of the underlying
      component is also invoked. Same test is repeated for different
      casing of the property name.
    - Introduces a new test case "destroy with existing handler" to test
      if unmounting works when the underlying component has `updated`
      hook.
    - Introduces the following two new test cases to test if the handler
      for a custom event is removed when unmounted:
        - "destroy with custom event"
        - "destroy with custom event and existing handler"
    - Renames `wrapper.destroy` with `wrapper.unmount` because
      `@vue/test-utils` V2 did so.
    - Mocks `BSlotComponent.refresh` instead of specifying `methods` to
      `shallowMount`, because `@vue/test-utils` no longer handles
      `methods` option.
    - Replaces `h` parameter of a `render` function with the global `h`.
    - Repalces `wrapper.name()` with `wrapper.vm.$options.name` because
      `wrapper.name` no longer exists in `@vue/test-utils` V2.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Renames `propsData` option for `shallowMount` with `props` because
      `propsData` might be deprecated in the future.
    - However, the tests won't pass until we fix the following issues:
        - #44
        - #45

issue #1
kikuomax added a commit that referenced this issue Aug 30, 2023
- Fixes the issue that `BSlotComponent` crashed with the following error
  if the underlying component has no slot: "TypeError: Cannot read
  properties of undefined (reading 'default')". Makes sure that the
  underlying component has slot before accessing it.

issue #44
kikuomax added a commit to kikuomax/buefy that referenced this issue Sep 5, 2023
- Updates the unit tests of `SlotComponent` so that they can work with
  `@vue/test-utils` V2, Vue 3, and breaking changes:
    - Calls `Component.vm.$forceUpdate` to emit the default "updated"
      lifecycle event instead of using `$emit`, because Vue 3
      differently handles lifecycle events from ordinary events.
    - Introduces a new test case "refresh on default event with existing
      handler" to test if `updated` hook of the underlying component is
      also invoked.
    - Introduces new test cases "refresh on custom event with existing
      handler (xyz)" to test if the event handler of the underlying
      component is also invoked. Same test is repeated for different
      casing of the property name.
    - Introduces a new test case "destroy with existing handler" to test
      if unmounting works when the underlying component has `updated`
      hook.
    - Introduces the following two new test cases to test if the handler
      for a custom event is removed when unmounted:
        - "destroy with custom event"
        - "destroy with custom event and existing handler"
    - Renames `wrapper.destroy` with `wrapper.unmount` because
      `@vue/test-utils` V2 did so.
    - Mocks `BSlotComponent.refresh` instead of specifying `methods` to
      `shallowMount`, because `@vue/test-utils` no longer handles
      `methods` option.
    - Replaces `h` parameter of a `render` function with the global `h`.
    - Repalces `wrapper.name()` with `wrapper.vm.$options.name` because
      `wrapper.name` no longer exists in `@vue/test-utils` V2.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Renames `propsData` option for `shallowMount` with `props` because
      `propsData` might be deprecated in the future.
    - However, the tests won't pass until we fix the following issues:
        - ntohq#44
        - ntohq#45

issue ntohq#1
wesdevpro pushed a commit that referenced this issue Sep 13, 2023
- Updates the unit tests of `SlotComponent` so that they can work with
  `@vue/test-utils` V2, Vue 3, and breaking changes:
    - Calls `Component.vm.$forceUpdate` to emit the default "updated"
      lifecycle event instead of using `$emit`, because Vue 3
      differently handles lifecycle events from ordinary events.
    - Introduces a new test case "refresh on default event with existing
      handler" to test if `updated` hook of the underlying component is
      also invoked.
    - Introduces new test cases "refresh on custom event with existing
      handler (xyz)" to test if the event handler of the underlying
      component is also invoked. Same test is repeated for different
      casing of the property name.
    - Introduces a new test case "destroy with existing handler" to test
      if unmounting works when the underlying component has `updated`
      hook.
    - Introduces the following two new test cases to test if the handler
      for a custom event is removed when unmounted:
        - "destroy with custom event"
        - "destroy with custom event and existing handler"
    - Renames `wrapper.destroy` with `wrapper.unmount` because
      `@vue/test-utils` V2 did so.
    - Mocks `BSlotComponent.refresh` instead of specifying `methods` to
      `shallowMount`, because `@vue/test-utils` no longer handles
      `methods` option.
    - Replaces `h` parameter of a `render` function with the global `h`.
    - Repalces `wrapper.name()` with `wrapper.vm.$options.name` because
      `wrapper.name` no longer exists in `@vue/test-utils` V2.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Renames `propsData` option for `shallowMount` with `props` because
      `propsData` might be deprecated in the future.
    - However, the tests won't pass until we fix the following issues:
        - #44
        - #45

issue #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant