Skip to content

Tests for default scopedSlots not mounting #706

Closed
@kayandra

Description

@kayandra

Version

1.0.0-beta.18

Reproduction link

https://codesandbox.io/s/0mrvjmvk6l

Steps to reproduce

Hi there, so I’m building a library for work and I’m using the render function and only accepting default scoped slots. I have the render function currently defined as

  render() {
      return this.$scopedSlots.default({ ...this.computedStateAndHelpers })
  },

When I try to write tests for it (using jest) I always get an error when trying to mount the component

const wrapper = shallowMount(Component, {
    scopedSlots: {
        default: () => '<p></p>'
    }
})
expect(wrapper.isVueInstance()).toBe(true)
expect(wrapper.name()).toBe('component-name')

I also tried

const wrapper = shallowMount(Component, {
    scopedSlots: {
        default: '<p></p>'
    }
})
expect(wrapper.isVueInstance()).toBe(true)
expect(wrapper.name()).toBe('component-name')

The error is

scopedSlots[key].trim is not a function

I don't know what I'm doing wrong, can someone please help me figure this out?

What is expected?

Expecting the test to pass

What is actually happening?

The error is

scopedSlots[key].trim is not a function

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions