How to use the jest-util.getPackageRoot 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 kulshekhar / ts-jest / src / coverageprocessor.ts View on Github external
function processResult(result: Result): Result {
  const root = require('jest-util').getPackageRoot();
  const jestConfig = getJestConfig(root).config;
  let sourceCache = {};
  let coveredFiles = [];

  let basepath = path.join(jestConfig.cacheDirectory, '/ts-jest/');
  if (!fs.existsSync(basepath)) {
    fs.mkdirSync(basepath);
  }
  let cachedFiles = fs.readdirSync(basepath);
  cachedFiles.map((p) => {
    let filename = new Buffer(p.replace(basepath, ''), 'base64').toString('utf8');
    // add back root part of filename
    // the root part was removed in the preprocessor.ts file to get shorter file names
    // long file names could be problematic in some OS
    // see https://github.com/kulshekhar/ts-jest/issues/158
    filename = root + filename;