How to use the jest-config.normalize function in jest-config

To help you get started, we’ve selected a few jest-config 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 / tests / __helpers__ / test-utils.ts View on Github external
argv: Arguments,
): null | JestConfigNormalize {
  /* tslint:disable */
  const R_OK = (fs.constants && fs.constants.R_OK) || (fs['R_OK'] as number);
  /* tslint:enable */
  try {
    fs.accessSync(filePath, R_OK);
  } catch (e) {
    return null;
  }

  const packageData = require(filePath);
  const config = packageData.jest || {};
  const root = path.dirname(filePath);
  config.rootDir = config.rootDir ? path.resolve(root, config.rootDir) : root;
  return normalize(config, argv);
}
github kulshekhar / ts-jest / tests / __helpers__ / test-utils.ts View on Github external
function readRawConfig(argv: Arguments, root: string): JestConfigNormalize {
  const rawConfig = parseConfig(argv);

  if (typeof rawConfig === 'string') {
    return loadJestConfigFromFile(path.resolve(process.cwd(), rawConfig), argv);
  }

  if (typeof rawConfig === 'object') {
    const config = Object.assign({}, rawConfig);
    config.rootDir = config.rootDir || root;
    return normalize(config, argv);
  }

  // Rawconfig is undefined
  const packageConfig = loadJestConfigFromPackage(
    path.join(root, 'package.json'),
    argv,
  );
  return packageConfig || normalize({ rootDir: root }, argv);
}
github kulshekhar / ts-jest / tests / __helpers__ / test-utils.ts View on Github external
if (typeof rawConfig === 'string') {
    return loadJestConfigFromFile(path.resolve(process.cwd(), rawConfig), argv);
  }

  if (typeof rawConfig === 'object') {
    const config = Object.assign({}, rawConfig);
    config.rootDir = config.rootDir || root;
    return normalize(config, argv);
  }

  // Rawconfig is undefined
  const packageConfig = loadJestConfigFromPackage(
    path.join(root, 'package.json'),
    argv,
  );
  return packageConfig || normalize({ rootDir: root }, argv);
}
github kulshekhar / ts-jest / tests / __helpers__ / test-utils.ts View on Github external
function loadJestConfigFromFile(
  filePath: string,
  argv: Arguments,
): JestConfigNormalize {
  const config = JSON.parse(fs.readFileSync(filePath, 'utf8'));
  config.rootDir = config.rootDir
    ? path.resolve(path.dirname(filePath), config.rootDir)
    : process.cwd();
  return normalize(config, argv);
}
github facebook / jest / packages / jest-runtime / src / __mocks__ / createRuntime.js View on Github external
module.exports = function createRuntime(filename, config) {
  const NodeEnvironment = require('jest-environment-node');
  const Runtime = require('../');

  const {normalize} = require('jest-config');

  config = normalize(
    {
      haste: {
        hasteImplModulePath: path.resolve(
          __dirname,
          '..',
          '..',
          '..',
          'jest-haste-map',
          'src',
          '__tests__',
          'haste_impl.js',
        ),
      },
      name: 'Runtime-' + filename.replace(/\W/, '-') + '.tests',
      rootDir: path.resolve(path.dirname(filename), 'test_root'),
      ...config,
github Raathigesh / majestic / app / src / core / engine / config / craConfig.ts View on Github external
export default function getConfig(rootPath: string): Config {
  return {
    jest: normalize(
      {
        rootDir: rootPath,
        testMatch: [
          '/src/**/__tests__/**/*.{js,jsx,mjs}',
          '/src/**/?(*.)(spec|test).{js,jsx,mjs}'
        ]
      },
      {}
    ).options,
    jestScript: resolveJestCliPath(
      rootPath,
      'react-scripts',
      'scripts/test.js'
    ),
    args: ['--env=jsdom'],
    env: {