// Load the JIT compiler BEFORE any Angular router/common imports import '@angular/compiler'; import { describe, it, expect, beforeEach, vi } from 'vitest'; import { Injector, PLATFORM_ID } from '@angular/core'; import { StructuredDataComponent } from './structured-data.component'; import { StructuredDataService } from '../services/structured-data.service'; describe('StructuredDataComponent — SSR compatibility', () => { let serviceMock: any; beforeEach(() => { serviceMock = { structuredData: vi.fn(() => []), }; }); it('should NOT throw when instantiated on the server platform', () => { expect(() => { Injector.create({ providers: [ { provide: PLATFORM_ID, useValue: 'server' }, { provide: StructuredDataService, useValue: serviceMock }, { provide: StructuredDataComponent, useFactory: () => new StructuredDataComponent(), deps: [], }, ], }); }).not.toThrow(); }); it('should instantiate without errors on the browser platform', () => { expect(() => { Injector.create({ providers: [ { provide: PLATFORM_ID, useValue: 'browser' }, { provide: StructuredDataService, useValue: serviceMock }, { provide: StructuredDataComponent, useFactory: () => new StructuredDataComponent(), deps: [], }, ], }); }).not.toThrow(); }); });