@@ -16,13 +16,9 @@ beforeEach(() => {
1616} ) ;
1717
1818/**
19- * Everything else in this suite tests one half of the feature: preprocessor.test.ts asserts on the
20- * string the preprocessor emits, profileComponent.test.ts calls __flareProfileComponent by hand. That
21- * leaves the join between them untested, which is where a regression would actually hide: emit a call
22- * the runtime no longer honours and both halves stay green while every span disappears.
23- *
24- * The fixtures under tests/fixtures/preprocessed/ contain no profiling code. The preprocessor is
25- * installed over them in vitest.config.mts, so these assertions run against injected code only.
19+ * preprocessor.test.ts checks what we emit, profileComponent.test.ts calls the function directly.
20+ * Neither notices if the emitted call stops working, so that gap gets its own test. The fixtures hold
21+ * no profiling code; vitest.config.mts injects it.
2622 */
2723describe ( 'preprocessor output at runtime' , ( ) => {
2824 it ( 'records the documented pageload tree for components carrying no profiling code' , async ( ) => {
@@ -31,15 +27,13 @@ describe('preprocessor output at runtime', () => {
3127
3228 const byName = Object . fromEntries ( fake . spans ( ) . map ( ( span ) => [ span . name , span ] ) ) ;
3329
34- // The names are the route-aware ones from the README table, produced end to end rather than
35- // asserted against resolveProfileName in isolation. Compared as a set: onMount is bottom-up,
36- // so the recording order is an implementation detail this assertion should not pin.
30+ // A set, because onMount runs bottom-up and we don't want to pin the recording order.
3731 expect ( new Set ( Object . keys ( byName ) ) ) . toEqual ( new Set ( [ '+layout' , 'product/[id]/+page' , 'AddToCartButton' ] ) ) ;
3832
39- // Harness matches no allowlist entry , so the layout parents straight to the active root.
33+ // Harness isn't in the allowlist , so the layout parents straight to the root.
4034 expect ( byName [ '+layout' ] ! . parent ) . toEqual ( { traceId : 'T' , parentSpanId : 'root' } ) ;
41- // The page reaches the layout only because snippet content inherits the context of the
42- // component that renders the snippet. This is the assertion that fails if that ever changes .
35+ // Only works because snippet content picks up the context of whoever renders it. If Svelte
36+ // ever changes that, this is the test that breaks .
4337 expect ( byName [ 'product/[id]/+page' ] ! . parent ) . toEqual ( {
4438 traceId : 'T' ,
4539 parentSpanId : byName [ '+layout' ] ! . spanId ,
@@ -50,18 +44,16 @@ describe('preprocessor output at runtime', () => {
5044 } ) ;
5145 } ) ;
5246
53- // AddToCartButton.svelte has no instance script, so the markup hook has to add a <script> block
54- // and the script hook then runs over that same block. Without the double-injection guard this
55- // component records two spans, or fails to compile on a duplicate declaration.
47+ // The markup hook adds a script block, then the script hook sees that same block. Without the
48+ // guard we'd inject twice.
5649 it ( 'injects exactly once into a component with no instance script' , async ( ) => {
5750 render ( Harness ) ;
5851 await tick ( ) ;
5952
6053 expect ( fake . spans ( ) . filter ( ( span ) => span . name === 'AddToCartButton' ) ) . toHaveLength ( 1 ) ;
6154 } ) ;
6255
63- // Only allowlisted components are instrumented. Harness renders and is a real component in the
64- // tree, but matches nothing, so it must be invisible rather than recording an unnamed span.
56+ // Harness is a real component in the tree but matches nothing, so it should stay invisible.
6557 it ( 'leaves unmatched components untouched' , async ( ) => {
6658 render ( Harness ) ;
6759 await tick ( ) ;
0 commit comments