Skip to main content
cngx-src documentation

createMockField

Functionforms/field/testing

projects/forms/field/testing/mock-field.ts

Description#

Creates a mock CngxFieldAccessor that returns a fully writable MockFieldRef. Tests can mutate any signal to simulate field state changes.

const { accessor, ref } = createMockField({ name: 'email', required: true });
// Pass `accessor` to [field] input
// Mutate ref.touched.set(true) to simulate interaction

Signature#

createMockField(opts: MockFieldOptions)

Parameters#

@paramoptsMockFieldOptions= {}

Returns#

literal type