MCPcopy
hub / github.com/sveltejs/svelte / run_test

Function run_test

packages/svelte/tests/signals/test.ts:27–40  ·  view source on GitHub ↗

* @param runes runes mode * @param fn A function that returns a function because we first need to set up all the signals * and then execute the test in order to simulate a real component

(runes: boolean, fn: (runes: boolean) => () => void)

Source from the content-addressed store, hash-verified

25 * and then execute the test in order to simulate a real component
26 */
27function run_test(runes: boolean, fn: (runes: boolean) => () => void) {
28 return () => {
29 // Create a component context to test runes vs legacy mode
30 push({}, runes);
31 // Create a render context so that effect validations etc don't fail
32 let execute: any;
33 const destroy = effect_root(() => {
34 execute = fn(runes);
35 });
36 pop();
37 execute();
38 destroy();
39 };
40}
41
42function test(text: string, fn: (runes: boolean) => any) {
43 it(`${text} (legacy mode)`, run_test(false, fn));

Callers 2

testFunction · 0.70
test.tsFile · 0.70

Calls 4

pushFunction · 0.90
effect_rootFunction · 0.90
popFunction · 0.90
fnFunction · 0.50

Tested by 1

testFunction · 0.56