Skip to content

Commit c04a13b

Browse files
committed
fix weird bug in tests
1 parent 8cd5635 commit c04a13b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/svelte/src/internal/client/reactivity/batch.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,13 @@ export class Batch {
302302
return current_batch;
303303
}
304304
}
305+
306+
/**
307+
* Forcibly remove all current batches
308+
* TODO investigate why we need this in tests
309+
*/
310+
export function clear() {
311+
for (const batch of batches) {
312+
batch.remove();
313+
}
314+
}

packages/svelte/tests/runtime-legacy/shared.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { assert_html_equal, assert_html_equal_with_options } from '../html_equal
1111
import { raf } from '../animation-helpers.js';
1212
import type { CompileOptions } from '#compiler';
1313
import { suite_with_variants, type BaseTest } from '../suite.js';
14+
import { clear } from '../../src/internal/client/reactivity/batch.js';
1415

1516
type Assert = typeof import('vitest').assert & {
1617
htmlEqual(a: string, b: string, description?: string): void;
@@ -521,6 +522,8 @@ async function run_test_variant(
521522
console.log = console_log;
522523
console.warn = console_warn;
523524
console.error = console_error;
525+
526+
clear();
524527
}
525528
}
526529

0 commit comments

Comments
 (0)