UNPKG

1.85 kBTypeScriptView Raw
1/**
2 * TestSandbox class provides a convenient way to get a reference to a
3 * sandbox folder in which you can perform operations for testing purposes.
4 */
5export declare class TestSandbox {
6 private _path?;
7 readonly path: string;
8 /**
9 * Will create a directory if it doesn't already exist. If it exists, you
10 * still get an instance of the TestSandbox.
11 *
12 * @param path - Path of the TestSandbox. If relative (it will be resolved relative to cwd()).
13 */
14 constructor(path: string);
15 /**
16 * Returns the path of the TestSandbox
17 */
18 getPath(): string;
19 /**
20 * Resets the TestSandbox. (Remove all files in it).
21 */
22 reset(): Promise<void>;
23 /**
24 * Deletes the TestSandbox.
25 */
26 delete(): Promise<void>;
27 /**
28 * Makes a directory in the TestSandbox
29 *
30 * @param dir - Name of directory to create (relative to TestSandbox path)
31 */
32 mkdir(dir: string): Promise<void>;
33 /**
34 * Copies a file from src to the TestSandbox. If copying a `.js` file which
35 * has an accompanying `.js.map` file in the src file location, the dest file
36 * will have its sourceMappingURL updated to point to the original file as
37 * an absolute path so you don't need to copy the map file.
38 *
39 * @param src - Absolute path of file to be copied to the TestSandbox
40 * @param dest - Optional. Destination filename of the copy operation
41 * (relative to TestSandbox). Original filename used if not specified.
42 */
43 copyFile(src: string, dest?: string): Promise<void>;
44 /**
45 * Creates a new file and writes the given data serialized as JSON.
46 *
47 * @param dest - Destination filename, optionally including a relative path.
48 * @param data - The data to write.
49 */
50 writeJsonFile(dest: string, data: unknown): Promise<void>;
51}