How to use the jest-util.createDirectory function in jest-util

To help you get started, we’ve selected a few jest-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-native-community / cli / jest / helpers.ts View on Github external
export const writeFiles = (
  directory: string,
  files: {[filename: string]: string},
) => {
  createDirectory(directory);
  Object.keys(files).forEach(fileOrPath => {
    const dirname = path.dirname(fileOrPath);

    if (dirname !== '/') {
      createDirectory(path.join(directory, dirname));
    }
    fs.writeFileSync(
      path.resolve(directory, ...fileOrPath.split('/')),
      files[fileOrPath],
    );
  });
};
github react-native-community / cli / jest / helpers.ts View on Github external
Object.keys(files).forEach(fileOrPath => {
    const dirname = path.dirname(fileOrPath);

    if (dirname !== '/') {
      createDirectory(path.join(directory, dirname));
    }
    fs.writeFileSync(
      path.resolve(directory, ...fileOrPath.split('/')),
      files[fileOrPath],
    );
  });
};
github facebook / jest / e2e / Utils.ts View on Github external
Object.keys(files).forEach(fileOrPath => {
    const dirname = path.dirname(fileOrPath);

    if (dirname !== '/') {
      createDirectory(path.join(directory, dirname));
    }
    fs.writeFileSync(
      path.resolve(directory, ...fileOrPath.split('/')),
      files[fileOrPath],
    );
  });
};
github facebook / jest / e2e / Utils.ts View on Github external
export const createEmptyPackage = (
  directory: Config.Path,
  packageJson?: {[keys: string]: any},
) => {
  const DEFAULT_PACKAGE_JSON = {
    description: 'THIS IS AN AUTOGENERATED FILE AND SHOULD NOT BE ADDED TO GIT',
    jest: {
      testEnvironment: 'node',
    },
  };

  createDirectory(directory);
  packageJson || (packageJson = DEFAULT_PACKAGE_JSON);
  fs.writeFileSync(
    path.resolve(directory, 'package.json'),
    JSON.stringify(packageJson, null, 2),
  );
};
github HubSpot / hubspot-cms-tools / packages / cms-cli / CommandTestEnvironment.js View on Github external
async setup() {
    await super.setup();

    const tmpDir = os.tmpdir();
    const localTestDir = path.join(tmpDir, 'hubspot-cms-tools-command-tests');
    const configFilePath = path.join(tmpDir, 'hubspot.config.yml');
    const hsPath = path.join(__dirname, binPaths.hs);
    const hscmsPath = path.join(__dirname, binPaths.hscms);

    this.global.hsPath = hsPath;
    this.global.hscmsPath = hscmsPath;
    this.global.localTestDir = localTestDir;
    this.global.configFilePath = configFilePath;
    this.global.configSource = configSourceTemplate(this.global);

    createDirectory(localTestDir);
    await fs.emptyDir(localTestDir);
    await fs.ensureFile(configFilePath);
    await fs.writeFile(configFilePath, configSourceTemplate(this.global));
  }
github facebook / jest / packages / jest-core / src / cli / index.ts View on Github external
configs.map(async (config, index) => {
      createDirectory(config.cacheDirectory);
      const hasteMapInstance = Runtime.createHasteMap(config, {
        console: new CustomConsole(outputStream, outputStream),
        maxWorkers: Math.max(
          1,
          Math.floor(globalConfig.maxWorkers / configs.length),
        ),
        resetCache: !config.cache,
        watch: globalConfig.watch || globalConfig.watchAll,
        watchman: globalConfig.watchman,
      });
      hasteMapInstances[index] = hasteMapInstance;
      return createContext(config, await hasteMapInstance.build());
    }),
  );
github facebook / jest / e2e / global-teardown / teardown.js View on Github external
return new Promise((resolve, reject) => {
    createDirectory(DIR);
    const fileId = crypto.randomBytes(20).toString('hex');
    fs.writeFileSync(path.join(DIR, fileId), 'teardown');
    resolve();
  });
};
github facebook / jest / e2e / global-setup / setup.js View on Github external
return new Promise((resolve, reject: any) => {
    createDirectory(DIR);
    const fileId = crypto.randomBytes(20).toString('hex');
    fs.writeFileSync(path.join(DIR, fileId), 'setup');
    resolve();
  });
};
github facebook / jest / e2e / global-teardown / project-2 / teardown.js View on Github external
return new Promise((resolve, reject) => {
    createDirectory(DIR);
    const fileId = crypto.randomBytes(20).toString('hex');
    fs.writeFileSync(path.join(DIR, fileId), 'teardown');
    resolve();
  });
};
github facebook / jest / e2e / global-teardown / project-1 / teardown.js View on Github external
return new Promise((resolve, reject) => {
    createDirectory(DIR);
    const fileId = crypto.randomBytes(20).toString('hex');
    fs.writeFileSync(path.join(DIR, fileId), 'teardown');
    resolve();
  });
};