mocha-pod / Exports / TestFs / TestFs
TestFs.TestFs
▸ TestFs(spec?, opts?): Disabled
Create a disabled testfs configuration from the given directory spec.
Calling the TestFs.Disabled.enable method will prepare the filesystem for testing operations.
IMPORTANT don't use this module in a real (non-containerized) system, specially with admin permissions, you risk leaving the system
in an inconsistent state if a crash happens before a restore() can be performed.
| Name | Type | Description |
|---|---|---|
spec? |
Directory |
Directory specification with files that need to be exist after set-up of the test fs. If the file exists previously in the given location it will be added to the keep list for restoring later. If it doesn't it will be added to the cleanup list to be removed during cleanup |
opts? |
Partial<Opts> |
Additional options for the test fs. |
- Disabled test fs configuration
▸ config(conf): void
| Name | Type |
|---|---|
conf |
Partial<Config> |
void
▸ file(f): FileSpec
Create a file specification from a partial file description
| Name | Type | Description |
|---|---|---|
f |
string | Buffer | Partial<FileSpec> |
file contents or partial file specification |
full file specification with defaults set
▸ from(f): FileRef
Create a file reference to an existing file
| Name | Type | Description |
|---|---|---|
f |
string | WithOptional<FileRef, keyof FileOpts> |
absolute or relative file path to create the reference from, if a relative path is given, process.cwd() will be used as basedir. This parameter can also be a partial FileRef specification |
full file reference specification with defaults set
▸ leftovers(): Promise<string[]>
Return any leftover backup files from previous invocations.
If any leftovers exist prior to running TestFs.Disabled.enable it means that a previous invocation did not terminate succesfully and is not safe to run the setup.
Promise<string[]>
▸ restore(): Promise<void>
Restore testsfs globally.
This function looks for a currently enabled instance of a test filesystem and calls TestFs.Enabled.restore on that instance.
Promise<void>