Efate is a JavaScript and TypeScript test fixture generator designed to address common pain points in managing test data within moderate to large web applications. It provides a type-safe API for defining and creating test fixtures, offering a robust alternative to static JSON files. The library, currently at version 1.5.1, aims to ensure consistent, unique, and understandable values for test objects while allowing specific field overrides for particular test cases. Its core differentiator lies in preventing 'Test Fixture Change Transference,' where modifying a fixture for one test can inadvertently affect subsequent tests in the same file. Efate enables the generation of individual mock objects or arrays of objects, with granular control over data generation and overriding capabilities, fostering more reliable and maintainable test suites. While no specific release cadence is noted in the provided material, the 1.x version series suggests a stable and actively maintained state for its current feature set.
npm install efateVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to define a type-safe fixture, create single objects with and without overrides, and generate arrays of fixtures.
Always treat generated fixtures as potentially mutable within the scope of a single test. If you need a completely independent copy for further modification, consider deep cloning the object, although Efate aims to make this unnecessary for initial creation.
Ensure you are using ECMAScript Module (ESM) `import` syntax: `import { createFixtureFactory } from 'efate';` within your TypeScript or modern JavaScript project configuration.Verify that your fixture definition precisely matches the fields and types declared in your generic interface. If adding new fields, update the interface first.
Review the documentation for `createArrayWith` carefully. For per-element control, pass an array of `Partial<T>` where `null` or `undefined` indicates no override for that specific index.
Update your TypeScript interface (`User` in this example) to include 'someInvalidField', or correct the field name in your fixture definition.
Ensure you are using `import { createFixtureFactory } from 'efate';` and that your project is configured for ESM or correctly transpiling CJS modules.Ensure `const userFixture = createFixture<User>(...)` is executed before `userFixture.create()` is called, and that both calls are within the same lexical scope.
No dependency data recorded yet.