Open
Description
Describe the bug
Testing rune effects as described in Svelte documentation is broken in Svelte > 5.1.11 and is double broken with vitest 3.2.x
Repo has logger.svelte.test.js
from documentation with latest svelte and vitest versions. Its expectation fails as flushSync()
seems to be ignored and code in $effect rune is not run.
Downgrading vitest version to 3.1.4 changes test behavior - it fails with effect_update_depth_exceeded
.
Downgrading Svelte as well to 5.1.11 or older makes test to pass.
Reproduction
Repo: https://github.com/vits/vitest-svelte-effects
Logs
Any version of Svelte 5 with vitest 3.2.x:
AssertionError: expected [] to deeply equal [ +0 ]
- Expected
+ Received
- [
- 0,
- ]
+ []
❯ src/logger.svelte.test.js:15:21
13| // use flushSync to execute all pending effects synchronously
14| flushSync();
15| expect(log.value).toEqual([0]);
| ^
16|
17| count = 1;
❯ update_reaction node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/client/runtime.js:414:56
❯ update_effect node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/client/runtime.js:580:18
❯ create_effect node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/client/reactivity/effects.js:118:17
❯ Module.effect_root node_modules/.pnpm/[email protected]/node_modules/svelte/src/internal/client/reactivity/effects.js:231:17
❯ src/logger.svelte.test.js:6:15
Svelte > 5.1.1 with vitest 3.1.4:
❯ client src/logger.svelte.test.js (1 test | 1 failed) 9ms
× Effect 8ms
→ effect_update_depth_exceeded
Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops
https://svelte.dev/e/effect_update_depth_exceeded
System Info
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M1 Pro
Memory: 96.94 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - ~/.local/share/mise/installs/node/22.14.0/bin/node
npm: 10.9.2 - ~/.local/share/mise/installs/node/22.14.0/bin/npm
pnpm: 9.15.7 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 137.0.7151.69
Edge: 137.0.3296.62
Safari: 18.5
npmPackages:
svelte: ^5.33.14 => 5.33.14
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels