Skip to content

Slots are not working #4

Open
@os-tohe

Description

When rendering slots, it throws this error:

SyntaxError: "prefixIdentifiers" option is not supported in this build of compiler.
 - /node_modules/.vite/deps/vitest-browser-vue.js:6404:30
 - /node_modules/.vite/deps/vitest-browser-vue.js:6706:20
 - /node_modules/.vite/deps/vitest-browser-vue.js:6722:21
 - /node_modules/.vite/deps/vitest-browser-vue.js:6711:122
 - /node_modules/.vite/deps/vitest-browser-vue.js:6890:16
 - /node_modules/.vite/deps/vitest-browser-vue.js:7034:47

I am testing with this setup:

TestComponent.vue

<template>
  <div>
    <div>Hello World</div>
    <slot></slot>
  </div>
</template>

<script setup lang="ts"></script>

TestComponent.browser.test.ts

import { render } from 'vitest-browser-vue';
import TestComponent from './TestComponent.vue';

describe('TestComponent', () => {
  test('Rendering slot', () => {
    render(TestComponent, {
      slots: {
        default: 'Test',
      },
    });
  });
});

While writing this issue I finally found a way which works:

default: () => 'Test'

So I needed to transform it into a function. Is this a bug or is this supposed to work like this? If this is not a bug then there should be some instructions on your documentation how to use the slots, since the slot declarations which are written in Vue Test Utils documentation do not work.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions