@gluonjs/test-utils / packages/test-utils/src/ssr / SsrFixture
Interface: SsrFixture
Properties
head
readonlyhead:string
html
readonlyhtml:string
name
readonlyname:string
response
readonlyresponse:SsrRequestResult
router
readonlyrouter:RouterSnapshot
state
readonlystate:string
stateScript
readonlystateScript:string
store
readonlystore:StoreSnapshot
styles
readonlystyles:StyleManifest
Methods
contains()
contains(
value):boolean
Parameters
value
string
Returns
boolean
Example
Inspect immutable server HTML, head carriers, serialized state, and the full public request result before hydration:
import type { SsrRequestResult } from '@gluonjs/ssr';
import {
activeSsrFixtureNames,
assertNoSsrFixtureLeaks,
cleanupSsrFixtures,
hydrateSsrFixture,
renderSsrFixture,
type HydratedSsrFixture,
type HydrateSsrFixtureOptions,
type HydrationFixtureContext,
type RenderSsrFixtureOptions,
type SsrFixture,
} from '@gluonjs/test-utils/ssr';
async function verifyShopRequest(render: () => Promise<SsrRequestResult>) {
const renderOptions = { name: 'shop-product' } satisfies RenderSsrFixtureOptions;
const server: SsrFixture = await renderSsrFixture(render, renderOptions);
const options = {
hydrate: async (context: HydrationFixtureContext) => ({
retained: context.container.querySelector('#product-title') !== null,
}),
dispose: () => undefined,
} satisfies HydrateSsrFixtureOptions<{ retained: boolean }>;
const fixture: HydratedSsrFixture<{ retained: boolean }> = await hydrateSsrFixture(server, options);
console.log(server.contains('Orbit Lamp'), fixture.hydrated.retained, activeSsrFixtureNames());
await fixture.cleanup();
await cleanupSsrFixtures();
assertNoSsrFixtureLeaks();
}
void verifyShopRequest;