How to use the jest-config.defaults 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 ionic-team / stencil / src / testing / jest / jest-config.ts View on Github external
export function buildJestConfig(config: d.Config) {
  const jestDefaults = require('jest-config').defaults;

  const validJestConfigKeys = Object.keys(jestDefaults);

  const jestConfig: d.JestConfig = {};

  Object.keys(config.testing).forEach(key => {
    if (validJestConfigKeys.includes(key)) {
      (jestConfig as any)[key] = (config.testing as any)[key];
    }
  });

  jestConfig.rootDir = config.rootDir;

  if (Array.isArray(config.testing.reporters)) {
    jestConfig.reporters = config.testing.reporters;
  }

  return JSON.stringify(jestConfig);