Page Contents
Home > @loopback/testlab > TestSandbox
TestSandbox class
TestSandbox class provides a convenient way to get a reference to a sandbox folder in which you can perform operations for testing purposes.
Signature:
export declare class TestSandbox
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(rootPath, options) | Will create a directory if it doesn’t already exist. If it exists, you still get an instance of the TestSandbox. |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
path | readonly |
string |
Methods
Method | Modifiers | Description |
---|---|---|
copyFile(src, dest, transform) | Copies a file from src to the TestSandbox. If copying a .js file which has an accompanying .js.map file in the src file location, the dest file will have its sourceMappingURL updated to point to the original file as an absolute path so you don’t need to copy the map file. |
|
delete() | Deletes the TestSandbox. | |
mkdir(dir) | Makes a directory in the TestSandbox | |
reset() | Resets the TestSandbox. (Remove all files in it). | |
writeJsonFile(dest, data) | Creates a new file and writes the given data serialized as JSON. | |
writeTextFile(dest, data) | Creates a new file and writes the given data as a UTF-8-encoded text. |