import fsExtra from 'fs-extra'; /** * Filesystem class exposes a consistent API to create, read and delete * files during tests. Apart from the generic CRUD operations, it * also takes care of the remove the modules from Node.js cache. * * ```js * const fs = new Filesystem() * * await fs.add('routes.js', `module.exports = 'routes'`) * await fs.remove('routes.js') // clears require cache * * // do it after every test to cleanup all generated files * await fs.cleanup() * ``` */ export declare class Filesystem { basePath: string; private modules; /** * Reference to fsExtra */ fsExtra: typeof fsExtra; constructor(basePath?: string); /** * Returns a boolean telling if file extension is part * of a Node.js module */ private isModule; /** * Makes abs path to a given file */ private makePath; /** * Removes ext from the file path */ private dropExt; /** * Removes the file path from nodejs module cache */ private removeFromModulesCache; /** * Store reference of a given file to clear it from the * modules cache at a later stage */ private trackModule; /** * Add a new file with given contents */ add(filePath: string, contents: string): Promise; /** * Returns true when file exists on the disk */ exists(filePath: string): Promise; /** * Creates base path dir (if missing) */ ensureRoot(): Promise; /** * Returns file contents */ get(filePath: string): Promise; /** * Remove file */ remove(filePath: string): Promise; /** * Cleanup all files and modules cache (if any) */ cleanup(): Promise; }