The `test-build-result` package provides a utility for comparing the output of a build process against a set of expected files or directories. This is crucial for integration testing, ensuring that build tools, compilers, or bundlers produce consistent and correct artifacts over time. It offers features for specifying actual and expected file paths, handling file content comparisons, and reporting discrepancies. As of version 1.1.2, the package has been updated with features like `testExists` to verify the presence of specific files and the ability to automatically generate expected directories if they do not exist, streamlining the setup for initial tests. The package maintains an active release cadence, with several minor updates recently, indicating ongoing maintenance and responsiveness to user needs. Its primary differentiator lies in its focused approach to asserting the correctness of filesystem-based build outputs, contrasting with more general-purpose assertion libraries.
npm install test-build-resultVerified import paths — ran on the pinned version, not inferred.
Demonstrates comparing a generated build output directory (`dist_actual`) with an expected output directory (`dist_expected`) using `testBuildResult`, showcasing how to identify discrepancies in build artifacts.
Use Node.js `path.normalize()` or `path.resolve()` when constructing paths for comparison. Consider using cross-platform path utilities if direct string comparison is part of your testing logic.
Always `await` the result of `testBuildResult` within an `async` function to ensure all comparisons are completed before the test finishes.
Identify dynamic parts of your build output and configure the `replaceContent` option to normalize these sections during comparison, or use a custom comparison logic for specific files.
Examine the detailed error message to identify the specific file(s) and discrepancies. Update your expected files if the new output is correct, or fix your build process if it's producing incorrect artifacts.
Ensure that both the actual build output directory and the expected reference directory exist before invoking `testBuildResult`. The package can generate `expectedDirPath` if it's missing (since v1.1.0) but `actualDirPath` must exist.
No dependency data recorded yet.