1. Constructors
  2. Constructor
  3. Accessors
  4. options
  5. root
  6. rootPath
  7. snapshot
  8. Methods
  9. at()
  10. copyFromExternal()
  11. destroy()
  12. dir()
  13. file()
  14. scaffold()
  15. setup()

Class: Sandbox

Defined in: packages/fs-testkit/src/sandbox.js:37

Constructors

Constructor

new Sandbox(options?): Sandbox;

Defined in: packages/fs-testkit/src/sandbox.js:93

Parameters

ParameterTypeDescription
options?Partial<InputSandboxOptions>-

Returns

Sandbox

Accessors

options

Get Signature

get options(): SettledSandboxOptions;

Defined in: packages/fs-testkit/src/sandbox.js:237

Read-only options used by the Sandbox instance. Can only be checked after setup has been called and all options have settled

Returns

SettledSandboxOptions


root

Get Signature

get root(): Dir;

Defined in: packages/fs-testkit/src/sandbox.js:229

The Dir representing the root directory of the sandbox

Returns

Dir


rootPath

Get Signature

get rootPath(): string;

Defined in: packages/fs-testkit/src/sandbox.js:220

The path to the root directory of the sandbox

Returns

string


snapshot

Get Signature

get snapshot(): Snapshot;

Defined in: packages/fs-testkit/src/sandbox.js:85

Returns

Snapshot

Methods

at()

at(path, type?): File | Dir;

Defined in: packages/fs-testkit/src/sandbox.js:289

Create a Dir or File at a given path relative to sandbox root. The returned instance is inferred based on whether the relative path has an extension, this can be forced by specifying the type argument.

Parameters

ParameterTypeDescription
pathstring-
type?"Dir" | "File"-

Returns

File | Dir


copyFromExternal()

copyFromExternal(srcAbsolutePath, options): Promise<(File | Dir)[]>;

Defined in: packages/fs-testkit/src/sandbox.js:310

Parameters

ParameterTypeDescription
srcAbsolutePathstring-
options| { as?: string; contentsOnly?: boolean; overwrite?: boolean; recursive?: boolean; } | undefined-

Returns

Promise<(File | Dir)[]>


destroy()

destroy(): Promise<void>;

Defined in: packages/fs-testkit/src/sandbox.js:318

Delete the sandbox root and its contents

Returns

Promise<void>


dir()

dir(name): Dir;

Defined in: packages/fs-testkit/src/sandbox.js:265

Create a Dir instance with the sandbox root as the parent

Parameters

ParameterTypeDescription
namestring-

Returns

Dir


file()

file(name): File;

Defined in: packages/fs-testkit/src/sandbox.js:256

Create a File instance with the sandbox root as the parent

Parameters

ParameterTypeDescription
namestring-

Returns

File


scaffold()

scaffold<T, Opts>(scaffoldDir, options?): Promise<ScaffoldResult<T, Opts>>;

Defined in: packages/fs-testkit/src/sandbox.js:301

Scaffold nested files and directories on the file system, from the sandbox root

Type Parameters

Type ParameterDefault typeDescription
T extends ScaffoldDir<ScaffoldFile>-
Opts extends ScaffoldOptionsobject

Parameters

ParameterTypeDescription
scaffoldDirT-
options?Opts-

Returns

Promise<ScaffoldResult<T, Opts>>


setup()

setup(): Promise<void>;

Defined in: packages/fs-testkit/src/sandbox.js:134

It is generally preferred to use createSandbox which will create an instance and handle async setup. Only call this function if creating an instance manually using the Sandbox constructor

Returns

Promise<void>