Skip to content

Latest commit

 

History

History
153 lines (86 loc) · 4.16 KB

TestFs.TestFs.md

File metadata and controls

153 lines (86 loc) · 4.16 KB

mocha-pod / Exports / TestFs / TestFs

Interface: TestFs

TestFs.TestFs

Callable

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.

Parameters

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.

Returns

Disabled

  • Disabled test fs configuration

Defined in

testfs/types.ts:183

Table of contents

Methods

Methods

config

▸ config(conf): void

Parameters

Name Type
conf Partial<Config>

Returns

void

Defined in

testfs/types.ts:190


file

▸ file(f): FileSpec

Create a file specification from a partial file description

Parameters

Name Type Description
f string | Buffer | Partial<FileSpec> file contents or partial file specification

Returns

FileSpec

full file specification with defaults set

Defined in

testfs/types.ts:215


from

▸ from(f): FileRef

Create a file reference to an existing file

Parameters

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

Returns

FileRef

full file reference specification with defaults set

Defined in

testfs/types.ts:224


leftovers

▸ 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.

Returns

Promise<string[]>

Defined in

testfs/types.ts:207


restore

▸ 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.

Returns

Promise<void>

Defined in

testfs/types.ts:198