@equinor/fusion-framework-cli
Version:
Command-line toolkit for developing, building, and publishing Fusion Framework applications and portal templates. Provides a unified developer experience from local development to production deployment.
41 lines • 1.3 kB
JavaScript
import assert from 'node:assert';
/**
* Lightweight assertion helper that provides a fluent API for value checks.
*
* Returns an object with `toBe` and `toBeInstanceOf` methods for asserting
* equality and type, respectively. Intended for internal CLI validation logic.
*
* @template T - The type of the value being asserted.
* @param value - The value to assert against.
* @returns An object with `toBe` and `toBeInstanceOf` assertion methods.
*
* @example
* ```ts
* expect(status).toBe(200, 'expected HTTP 200');
* expect(result).toBeInstanceOf('object', 'expected an object');
* ```
*/
export const expect = (value) => {
return {
toBe: (expected, message) => {
assert(value === expected, Error(message, {
cause: {
expected,
actual: value,
value,
},
}));
},
toBeInstanceOf: (expected, message) => {
const actual = typeof value;
assert(actual === expected, Error(message, {
cause: {
expected,
actual,
value: value === undefined ? 'undefined' : value,
},
}));
},
};
};
//# sourceMappingURL=expect.js.map