-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Labels
awaiting submitterneeds a reproduction, or clarificationneeds a reproduction, or clarification
Description
Describe the bug
Using vitest, and @testing-library/svelte in our codebase we were testing Snippets in different area using the render
function from the testing library (see reproduction).
Recently with #15521 it has been added some extra validation when rendering Snippet. And our CI failed when dependabot tried to update svelte library.
The problem seems to be that the testing library calls the Snippet function with an empty object as argument, and fails at the following part of the code
svelte/packages/svelte/src/internal/client/dev/validation.js
Lines 10 to 14 in e72ac0f
for (let arg of args) { | |
if (typeof arg !== 'function') { | |
invalid_snippet_arguments(); | |
} | |
} |
Raising an invalid_snippet_arguments error.
Reproduction
Example.svelte
<script module>
export { add };
</script>
{#snippet add(a, b)}
{a} + {b} = {a + b}
{/snippet}
example.spec.ts
import '@testing-library/jest-dom/vitest';
import { render } from '@testing-library/svelte';
import { add } from './Example.svelte';
import { test } from 'vitest';
test('render snippet', () => {
render(add);
});
Logs
Svelte error: invalid_snippet_arguments
A snippet function was passed invalid arguments. Snippets should only be instantiated via `{@render ...}`
https://svelte.dev/e/invalid_snippet_arguments
System Info
all platform (macos, ubuntu, windows)
Severity
blocking an upgrade
Metadata
Metadata
Assignees
Labels
awaiting submitterneeds a reproduction, or clarificationneeds a reproduction, or clarification