Functions

@system-inc/base-foundation · 515c140 · 3 symbols

Parses a Set-Cookie header into a map of cookie names to values.

Accepts an optional type argument so call sites with a known cookie shape can narrow the result:

const cookies = parseSetCookie<{ deviceId: string; sessionId: string }>(header);
parseSetCookie(input: string): Partial<T>

View source ↗

To be used ONLY by jest.setup.ts to set the integration test environment.

setIntegrationTestEnvironment(integrationTestEnvironment: IntegrationTestEnvironment): void

View source ↗

uniqueTestId

function

Generates a unique identifier for use in integration tests that hit a persistent database.

Why: tests accumulate rows over time. A pure Math.random() * 1_000_000 suffix collides via birthday paradox after enough runs, surfacing as spurious "already taken" / unique-constraint failures. Combining the current epoch with a random number partitions the namespace per millisecond, so collisions require both a same-ms concurrent run AND the same random draw.

Default format: ${prefix}${sep}${epochMs}${sep}${rand} — roughly 25 characters with a - separator. Use UniqueTestIdOptions.maxLength when the consuming field can't fit that much.

uniqueTestId(prefix: string, options: UniqueTestIdOptions): string
  • prefix

    Text to prepend (e.g. `'test'`, `'testorg'`, `'qtest'`).

  • options

    See [UniqueTestIdOptions](#test/IntegrationTestIds#UniqueTestIdOptions).

View source ↗

Functions • Documentation • Base