Questions tagged [svelte-testing-library]

Questions about testing Svelte components with the svelte-testing-library utility.

8 questions
4
votes
1 answer

Svelte testing library won't detect component updates

My component:

{sentence}

johannchopin
  • 13,720
  • 10
  • 55
  • 101
2
votes
2 answers

How to test Svelte component props with Vitest?

I want to test the props of a Svelte component with Vitest. Component:
{foo}
Test: const { component } = render(MyComponent, { foo: 'bar' }) expect(component.foo).toBe('bar') When I run this test, I…
Yulian
  • 6,262
  • 10
  • 65
  • 92
2
votes
1 answer

How to test the reaction to a component event in Svelte?

In Svelte, I have a parent component which listens to a component event dispatched by a child component. I know how to use component.$on to check that the dispatched event does the right thing within the component which is dispatching, like so. But…
jrh
  • 4,101
  • 2
  • 22
  • 27
1
vote
1 answer

Svelte - Not able to fetch data from JSON file during jest unit testing

During unit testing, I am getting undefined error, while executing svelte component with json file. Restaurant.svelte : import data from '../Data/restaurants.json'; console.log(data); let finalData = data.restaurants; restaurant.spec.js : import…
0
votes
0 answers

How to test Svelte Material UI Select options with Testing-Library/Vitest?

I am using the Svelte Material UI select menu component to control whether some items are displayed in my Svelte project. I would like to test whether for a given input the correct items are being displayed. Unfortunately, I can't figure out how to…
0
votes
0 answers

How to test html special characters in Testing Library

In Svelte component I have a tag:

{@html organisation_name}

Organisation name comes with Special Character Code, like so: const organisation_name = 'TJ's Org 2' I'm using Svelte @html tag so it renders…
dariusz
  • 441
  • 1
  • 5
  • 17
0
votes
1 answer

Difference between fireEvent.dblClick & fireEvent.doubleClick in testing library?

Question about 2 different methods exposed via fireEvent API in the react-testing-library. fireEvent.dblClick fireEvent.doubleClick What's the difference? And is there a recommendation to use one over the other?