A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/testing-library/svelte-testing-library/issues/196 below:

How to render components with accessors: true? · Issue #196 · testing-library/svelte-testing-library · GitHub

How can I render a component with accessors set to true?
According to this release, it looks like it should exist.

But when I do this:

const utils = render(Input, {
    accessors: true,
    props: { value: "foo"},
  })

I get this:

- Error:
-         Unknown options were found [accessors]. This might happen if you've mixed                      
-         passing in props with Svelte options into the render function. Valid Svelte options            
-         are [anchor,props,hydrate,intro,context]. You can either change the prop names, or pass in your
-         props for that component via the `props` option.                                               
-                                                                                                        
-         Eg: const { /** Results **/ } = render(MyComponent, { props: { /** props here **/ } })         

Also when I try to access the prop directly like this:

I get this:

- Error: <VolumeControl>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'

I also found this from here, which does work:

const utils = render(Input, { value: "" });
const component = utils.component.$$;
/*
* Update component such that value = asdf
*/
expect(component.ctx[component.props["value"]]).toBe("asdf")

But I have no idea why this works and it is undocumented. It is also quite cumbersome to write.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4