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

BNavbar crashed with "TypeError: this.$slots.brand is not a function" #28

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

Comments

@kikuomax
Copy link
Collaborator

Overview of the problem

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

Description

An empty <b-navbar> crashed with the following error:

TypeError: this.$slots.brand is not a function

Steps to reproduce

<b-navbar></b-navbar>

I encountered this while working on unit tests of Navbar:

Expected behavior

No error is thrown.

Actual behavior

It threw an error.

@kikuomax kikuomax added the bug Something isn't working label Aug 11, 2023
kikuomax added a commit to kikuomax/buefy that referenced this issue Aug 14, 2023
- Fixes the bug where an empty `BNavbar` crashed with "TypeError:
  this.$slots.brand is not a function". Checks if `this.$slots.brand` is
  not nullish before calling it.

issue ntohq#28
kikuomax added a commit that referenced this issue Aug 14, 2023
- Updates the unit tests (spec) of `Navbar` so that they can work with
  `@vue/test-utils` V2 and breaking changes:
    - Corrects v-model bindings:
        - property: `active` → `modelValue`
        - event: `update:active` → `update:modelValue`
    - Replaces `wrapper.contains` with a combination of `find` and
      `exists` because `wrapper.contains` no longer exists in
      `@vue/test-utils` V2.
    - Awaits `wrapper.setProps` and `wrapper.trigger` to make sure the
      subsequent tests verify the updated state.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Replaces `propsData` for `mount` with `props` because `propsData`
      might be deprecated in the future.
    - Refreshes the snapshot. I did not find any problems in the updated
      snapshot. However, the snpshot won't match until we fix the issue
      #29.
    - The tests won't pass until we fix the issue #28.

issue #1
kikuomax added a commit that referenced this issue Aug 22, 2023
…on" (#28) (#30)

* fix(lib): crash of empty BNavbar

- Fixes the bug where an empty `BNavbar` crashed with "TypeError:
  this.$slots.brand is not a function". Checks if `this.$slots.brand` is
  not nullish before calling it.

issue #28
@kikuomax kikuomax self-assigned this Aug 30, 2023
kikuomax added a commit to kikuomax/buefy that referenced this issue Sep 4, 2023
- Updates the unit tests (spec) of `Navbar` so that they can work with
  `@vue/test-utils` V2 and breaking changes:
    - Corrects v-model bindings:
        - property: `active` → `modelValue`
        - event: `update:active` → `update:modelValue`
    - Replaces `wrapper.contains` with a combination of `find` and
      `exists` because `wrapper.contains` no longer exists in
      `@vue/test-utils` V2.
    - Awaits `wrapper.setProps` and `wrapper.trigger` to make sure the
      subsequent tests verify the updated state.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Replaces `propsData` for `mount` with `props` because `propsData`
      might be deprecated in the future.
    - Refreshes the snapshot. I did not find any problems in the updated
      snapshot. However, the snpshot won't match until we fix the issue
      ntohq#29.
    - The tests won't pass until we fix the issue ntohq#28.

issue ntohq#1
wesdevpro pushed a commit that referenced this issue Sep 16, 2023
* test(lib): update Navbar spec

- Updates the unit tests (spec) of `Navbar` so that they can work with
  `@vue/test-utils` V2 and breaking changes:
    - Corrects v-model bindings:
        - property: `active` → `modelValue`
        - event: `update:active` → `update:modelValue`
    - Replaces `wrapper.contains` with a combination of `find` and
      `exists` because `wrapper.contains` no longer exists in
      `@vue/test-utils` V2.
    - Awaits `wrapper.setProps` and `wrapper.trigger` to make sure the
      subsequent tests verify the updated state.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Replaces `propsData` for `mount` with `props` because `propsData`
      might be deprecated in the future.
    - Refreshes the snapshot. I did not find any problems in the updated
      snapshot. However, the snpshot won't match until we fix the issue
      #29.
    - The tests won't pass until we fix the issue #28.

issue #1

* test(lib): update NavbarBurger spec

- Updates the unit tests (spec) of `NavbarBurger` so that they can work
  with `@vue/test-utils` V2:
    - Specifies the element tag to the selector given to `wrapper.find`
      instead of testing the tag with `is`. Because `is` no longer
      exists in `@vue/test-utils` V2.
    - Awaits `wrapper.setProps` to make sure the subsequent assertions
      verify the updated state.
    - Replaces the test on `wrapper.isVueInstance()` with presence of
      `wrapper.vm` because `wrapper.isVueInstance` no longer exists in
      `@vue/test-utils` V2.
    - Refreshes the snapshot. I did not find any problems in the updated
      snapshot. However, the snapshot won't match until we fix the issue
      #29.

issue #1

* test(lib): update NavbarItem spec

- Updates the unit tests (spec) of `NavbarItem` so that they can work
  with `@vue/test-utils` V2 and Vue 3:
    - Replaces `listeners` option for `shallowMount` with `on{event}`
      props, because `listeners` no longer works on `@vue/test-utils` V2
      but `on{event}` prop does the equivalent job on Vue 3 instead.
    - Mounts `stubBNavBar` and inserts `BNavbarItem` into its default
      slot instead of specifying `stubBNavBar` as `parentComponents`,
      because `parentComponents` no longer works on `@vue/test-utils`
      V2.
    - Replaces `wrapper.contains` with a combination of `find` and
      `exists` because `wrapper.contains` no longer exists in
      `@vue/test-utils` V2.
    - A test on a tag name is merged with a selector given to `find`.
    - Awaits `wrapper.setProps` to make sure the subsequent assertions
      verify the updated state.
    - Replaces `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.
    - Fixes the event type for "click": `KeyboardEvent` → `MouseEvent`.
    - Replaces `sinon.stub` with `jest.fn`. No longer imports `sinon`.

issue #1

* test(lib): update NavbarDropdown spec

- Updates the unit tests (spec) of `NavbarDropdown` so that they can
  work with `@vue/test-utils` V2:
    - Awaits `wrapper.setProps` to make sure the subsequent assertions
      verify the updated state.
    - Replaces `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 loger exists in
      `@vue/test-utils` V2.
    - Refreshes the snapshot. I found the updated snapshot had two
      `div` elements with `navbar-dropdown` class, but this is fine
      because they were introduced after the old snapshot was recorded.

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