2025SELab2-project-Dwengo/backend/tests/test-utils/load-test-asset.ts
2025-04-18 23:36:22 +00:00

14 lines
440 B
TypeScript

import fs from 'fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const fileName = fileURLToPath(import.meta.url);
const dirName = path.dirname(fileName);
/**
* Load the asset at the given path.
* @param relPath Path of the asset relative to the test-assets folder.
*/
export function loadTestAsset(relPath: string): Buffer {
return fs.readFileSync(path.resolve(dirName, `../test_assets/${relPath}`));
}