How to use the jest-validate.validate function in jest-validate

To help you get started, we’ve selected a few jest-validate 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 ehmicky / gulp-execa / src / options / main.js View on Github external
const validateOpts = function({ opts, defaultOpts, forcedOpts }) {
  const exampleConfig = filterObj(
    { ...EXAMPLE_OPTS, ...defaultOpts },
    key => !hasOwnProperty.call(forcedOpts, key),
  )

  try {
    validate(opts, { exampleConfig, recursiveBlacklist: ['env'] })
  } catch (error) {
    // `jest-validate` `error.stack` just repeats `error.message`
    throwError(error, { showStack: false })
  }

  validateCustom({ opts })
}
github facebook / metro / packages / metro-config / src / loadConfig.js View on Github external
async function loadConfig(
  argv?: YargArguments = {},
  defaultConfigOverrides?: InputConfigT = {},
): Promise {
  argv.config = overrideArgument(argv.config);

  const configuration = await loadMetroConfigFromDisk(
    argv.config,
    argv.cwd,
    defaultConfigOverrides,
  );

  validate(configuration, {
    exampleConfig: await validConfig(),
    recursiveBlacklist: ['reporter', 'resolver', 'transformer'],
  });

  // Override the configuration with cli parameters
  const configWithArgs = overrideConfigWithArguments(configuration, argv);

  const overriddenConfig = {};

  // The resolver breaks if "json" is missing from `resolver.sourceExts`
  const sourceExts = configWithArgs.resolver.sourceExts;
  if (!configWithArgs.resolver.sourceExts.includes('json')) {
    overriddenConfig.resolver = {
      sourceExts: [...sourceExts, 'json'],
    };
  }
github facebook / jest / packages / jest-config / src / normalize.ts View on Github external
export default function normalize(
  initialOptions: Config.InitialOptions,
  argv: Config.Argv,
  configPath?: Config.Path | null,
  projectIndex: number = Infinity,
): {
  hasDeprecationWarnings: boolean;
  options: AllOptions;
} {
  const {hasDeprecationWarnings} = validate(initialOptions, {
    comment: DOCUMENTATION_NOTE,
    deprecatedConfig: DEPRECATED_CONFIG,
    exampleConfig: VALID_CONFIG,
    recursiveBlacklist: [
      'collectCoverageOnlyFrom',
      // 'coverageThreshold' allows to use 'global' and glob strings on the same
      // level, there's currently no way we can deal with such config
      'coverageThreshold',
      'globals',
      'moduleNameMapper',
      'testEnvironmentOptions',
      'transform',
    ],
  });

  let options = normalizePreprocessor(
github lingui / js-lingui / packages / conf / src / index.js View on Github external
export function getConfig({ cwd, configPath } = {}) {
  const configExplorer = cosmiconfig("lingui")
  const defaultRootDir = cwd || process.cwd()

  const result = configExists(configPath)
    ? configExplorer.loadSync(configPath)
    : configExplorer.searchSync(defaultRootDir)

  const raw = { ...defaultConfig, ...(result ? result.config : {}) }

  validate(raw, configValidation)
  // Use deprecated fallbackLanguage, if defined
  raw.fallbackLocale = raw.fallbackLocale || raw.fallbackLanguage || ""

  const rootDir = result ? path.dirname(result.filepath) : defaultRootDir
  return replaceRootDir(raw, rootDir)
}
github ehmicky / log-process-errors / src / options / main.js View on Github external
export const getOptions = function({ opts = {} }) {
  const optsA = filterObj(opts, isDefined)

  validate(optsA, { exampleConfig: EXAMPLE_OPTS })
  validateOptions(optsA)

  const optsB = applyTesting({ opts: optsA })
  const level = applyDefaultLevels({ opts: optsB })
  const optsC = { ...DEFAULT_OPTS, ...optsB, level }

  const optsD = addChalk({ opts: optsC })
  return optsD
}
github ehmicky / log-process-errors / src / options.js View on Github external
const getOptions = function({ opts }) {
  const optsA = pickBy(opts, value => value !== undefined)

  validate(optsA, { exampleConfig: DEFAULT_OPTS })

  const optsB = { ...DEFAULT_OPTS, ...optsA }
  return optsB
}

jest-validate

Generic configuration validation tool that helps you with warnings, errors and deprecation messages as well as showing users examples of correct configuration.

MIT
Latest version published 1 year ago

Package Health Score

88 / 100
Full package analysis

Similar packages