lite-fixture is a lightweight utility designed to create and manage temporary DOM elements for browser-based testing environments. It simplifies the setup and teardown of test fixtures, allowing developers to easily create a `sandbox` element (or multiple with specific IDs/styles) and ensure their removal using `cleanup()`. The current stable version is 1.0.2. It focuses on minimal API surface for direct DOM manipulation, making it suitable for simple unit tests that require a live DOM. While functional and stable, the package appears to be minimally maintained, with its last update several years ago, which implies a low release cadence. Its primary differentiator is its extreme simplicity and small footprint compared to more comprehensive testing frameworks.
npm install lite-fixtureVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to create various sandbox elements with default or custom IDs and styles, add content to them, and crucially, how to clean them up after tests using `cleanup()`.
Call `cleanup()` in an `afterEach` or `afterAll` hook of your testing framework, or manually at the end of each test.
Ensure your test environment provides a DOM (e.g., running tests in a browser or configuring JSDOM for Node.js tests).
Evaluate if the simplicity of `lite-fixture` still meets your needs or if a more actively maintained library or testing framework's built-in fixture handling is more appropriate for modern web development.
Use a tool like JSDOM in your Node.js test setup to provide a global `document` object, or run your tests in a browser environment.
Ensure `cleanup()` is only called for existing sandbox elements. If using `cleanup()` without arguments, ensure there is a default sandbox. Consider wrapping `cleanup` calls in a `try...catch` block or checking for element existence before cleanup if multiple cleanup attempts are possible.
No dependency data recorded yet.