@appsemble/node-utils
Version:
NodeJS utilities used by Appsemble internally.
41 lines (40 loc) • 1.35 kB
TypeScript
import { type ReadStream } from 'node:fs';
/**
* Set the test fixture base path. This folder should contain a folder named `__fixtures__`.
*
* This is typically called in `vitest.setup.ts`.
*
* @param meta The module meta object
* @example
* ```ts
* setFixtureBase(import.meta);
* ```
*/
export declare function setFixtureBase(meta: ImportMeta): void;
/**
* Resolve the path to a test fixture.
*
* @param path The path to resolve relative to the fixture base. It will be normalized for the
* operating system.
* @returns The full path to the fixture path.
*/
export declare function resolveFixture(path: string): string;
/**
* Read a test fixture.
*
* @param path The path to resolve relative to the fixture base. It will be normalized for the
* operating system.
*
* param encoding The text encoding of the file.
* @returns The file contents as a string or buffer.
*/
export declare function readFixture(path: string): Promise<Buffer>;
export declare function readFixture(path: string, encoding: BufferEncoding): Promise<string>;
/**
* Create a read stream for a fixture.
*
* @param path The path to resolve relative to the fixture base. It will be normalized for the
* operating system.
* @returns A filesystem read stream for the fixture.
*/
export declare function createFixtureStream(path: string): ReadStream;