test-filesystem
    Preparing search index...

    Variable filesystemConst

    filesystem: {
        copyRealModules: (
            destModulesDir: string,
            moduleNames: string[],
            sourceModulesDir?: string,
        ) => void;
        fileExists: (filePath: string) => boolean;
        removeDirectory: (dirPath: string) => Promise<any>;
        setUp: {
            afterEach: () => Promise<any>;
            beforeEach: () => Promise<any>;
            createTempDir: (exists?: boolean) => Promise<any>;
            setDefaults: (dirPath?: string) => void;
        };
        writeFixtureFile: (filePath: string, content: string) => void;
        writePackageJson: (dirPath: string, fields: Record<string, any>) => void;
    } = ...

    Type Declaration

    • copyRealModules: (
          destModulesDir: string,
          moduleNames: string[],
          sourceModulesDir?: string,
      ) => void

      Copy real, installed node_modules packages into a destination directory, for use as realistic test fixtures instead of hand-written stand-ins.

    • fileExists: (filePath: string) => boolean

      Detect if a file exists and is usable.

    • removeDirectory: (dirPath: string) => Promise<any>

      Return a promise to be completed once the specified directory is deleted.

    • setUp: {
          afterEach: () => Promise<any>;
          beforeEach: () => Promise<any>;
          createTempDir: (exists?: boolean) => Promise<any>;
          setDefaults: (dirPath?: string) => void;
      }
      • afterEach: () => Promise<any>

        In the Jest.afterEach function call this one to clean up and remove the temp directory.

      • beforeEach: () => Promise<any>

        In the Jest.beforeEach function call this one to set up the temp directory.

      • createTempDir: (exists?: boolean) => Promise<any>

        Ensure that the del has completed, recursively attempt to delete and recreate

      • setDefaults: (dirPath?: string) => void

        Override the temp directory path used by afterEach, beforeEach, and createTempDir. Call this once, before your tests run, if the default ('test-temp/') doesn't suit your project.

    • writeFixtureFile: (filePath: string, content: string) => void

      Write a file, creating any missing parent directories first.

    • writePackageJson: (dirPath: string, fields: Record<string, any>) => void

      Write a package.json file for a directory, creating any missing parent directories first. Parses and re-serializes with a plain 2-space indent regardless of how fields was built, so callers never need to worry about matching JSON formatting by hand.