← Back to Discord Forum

Component Testing with Svelte: Error: Target closed when passing an array as prop

iamthewraithposted in #help-playwright
Open in Discord


I am using SvelteKit and trying to use Playwright's experimental component testing. I have a component that takes 2 props, one is a string, the other is an array of objects. When I pass the string prop, everything works fine. When I pass the array of objects, I get the error:

Error: Target closed


Svelte: 3.54.0 SvelteKit: 1.5.0 Playwright: 1.36.0


this works just fine:

test('should display a custom loading message', async ({ mount }) => {
  const text = 'Doing stuff...';
  const component = await mount(Loading, {
    props: { text },

  const loadingText = component.locator('.loading-indicator');
  await expect(loadingText).toContainText(`${text}...`);

but this fails:

test('should display a quote when quotes are passed in', async ({ mount }) => {
  const quotes: IQuote[] = [
      quote: 'some quote.',
      author: 'some person'

  const component = await mount(Loading, {
    props: { quotes },

  const loadingText = component.locator('.loading-indicator');
  await expect(loadingText).toContainText('loading...');

Does anyone have any ideas why this is happening?

This thread is trying to answer question "Why does passing an array of objects as a prop in Playwright's experimental component testing with SvelteKit result in an 'Error: Target closed' message?"

0 replies

Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.