How to use the ts-jest/presets.defaults.transform function in ts-jest

To help you get started, we’ve selected a few ts-jest 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 jupyterlab / jupyterlab-data-explorer / etc / jest / jest.config.js View on Github external
// Resolve the root project directory:
const ROOT = resolve(__dirname, '..', '..');

const config = {
  rootDir: ROOT,

  // Needed for jest-screenshots
  testRunner: 'jest-circus/runner',

  testEnvironment: resolve(__dirname, 'jest-environment.js'),
  globalSetup: 'jest-environment-puppeteer/setup',
  globalTeardown: 'jest-environment-puppeteer/teardown',
  setupFilesAfterEnv: ['expect-puppeteer'],
  transform: {
    ...tsjPreset.transform
  },
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  testMatch: ['**/test/**/test*.ts?(x)'],
  testPathIgnorePatterns: ['/build/', '/lib/', '/node_modules/'],
  globals: {
    'ts-jest': {
      tsConfig: resolve(ROOT, 'tsconfig.test.json')
    }
  }
};

/**
 * Exports.
 */
module.exports = config;
github SolidZORO / leaa / packages / leaa-api / jest.config.js View on Github external
/* eslint-disable import/no-extraneous-dependencies */
const { defaults: tsjPreset } = require('ts-jest/presets');

// 🔰 Tips, if `tsconfig.json`, here will be open
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');

module.exports = {
  transform: {
    ...tsjPreset.transform,
    '^.+\\.tsx?$': 'ts-jest',
  },
  moduleFileExtensions: ['ts', 'js'],
  //
  // 🔰 Tips, if `tsconfig.json`, here will be open
  moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '/' }),
  //
  modulePathIgnorePatterns: ['/_dist/', '/_deploy/'],
  testRegex: 'src.*\\.(test|spec).(ts|tsx|js)$',
  collectCoverageFrom: [
    'src/**/*.{js,jsx,tsx,ts}',
    '!**/node_modules/**',
    '!**/vendor/**',
    '!**/dist/**',
    '!**/_dist/**',
    '!**/_deploy/**',
github SolidZORO / leaa / packages / leaa-api / jest-e2e.config.js View on Github external
/* eslint-disable import/no-extraneous-dependencies */
const { defaults: tsjPreset } = require('ts-jest/presets');

// 🔰 Tips, if `tsconfig.json`, here will be open
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');

module.exports = {
  transform: {
    ...tsjPreset.transform,
    '^.+\\.(t|j)s$': 'ts-jest',
  },
  moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
  //
  // 🔰 Tips, if `tsconfig.json`, here will be open
  moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '/' }),
  //
  testRegex: '.e2e-(test|spec).ts$',
  collectCoverageFrom: [
    'src/**/*.{js,jsx,tsx,ts}',
    '!**/node_modules/**',
    '!**/vendor/**',
    '!**/dist/**',
    '!**/_dist/**',
    '!**/_deploy/**',
  ],
github oliviertassinari / react-swipeable-views / native / jest.config.js View on Github external
const { defaults: tsjPreset } = require('ts-jest/presets');

module.exports = {
  ...tsjPreset,
  preset: 'react-native',
  transform: {
    ...tsjPreset.transform,
    '\\.js$': '/node_modules/react-native/jest/preprocessor.js',
  },
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  // This is the only part which you can keep
  // from the above linked tutorial"s config:
  cacheDirectory: '.jest/cache',
};
github jupyterlab / jupyterlab-metadata-service / etc / jest / jest.config.js View on Github external
// Resolve the root project directory:
const ROOT = resolve(__dirname, '..', '..');

const config = {
  rootDir: ROOT,

  // Needed for jest-screenshots
  testRunner: 'jest-circus/runner',

  testEnvironment: resolve(__dirname, 'jest-environment.js'),
  globalSetup: 'jest-environment-puppeteer/setup',
  globalTeardown: 'jest-environment-puppeteer/teardown',
  setupFilesAfterEnv: ['expect-puppeteer'],
  transform: {
    ...tsjPreset.transform
  },
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  testMatch: ['**/test/**/test*.ts?(x)'],
  testPathIgnorePatterns: ['/build/', '/lib/', '/node_modules/'],
  globals: {
    'ts-jest': {
      tsConfig: resolve(ROOT, 'tsconfig.test.json')
    }
  }
};

/**
 * Exports.
 */
module.exports = config;
github ant-design / ant-design-mobile-rn / .jest.config.js View on Github external
setupFiles: ['./tests/setup.js'],
  moduleFileExtensions: [
    'ts',
    'tsx',
    'js',
    'jsx',
    'json',
  ],
  testPathIgnorePatterns: [
    '/node_modules/',
    '_site',
    'site',
  ],
  transform: {
    // '\\.tsx?$': 'ts-jest',
    ...tsjPreset.transform,
    // '\\.tsx?$': './node_modules/antd-tools/lib/jest/codePreprocessor',
    // '\\.js$': './node_modules/antd-tools/lib/jest/codePreprocessor',
    '^.+\\.js$': '/node_modules/react-native/jest/preprocessor.js',
    '\\.png': '/tests/imageStub.js',
  },
  testRegex: libDir === 'dist' ? 'demo\\.test\\.js$' : '.*\\.test\\.js$',
  collectCoverageFrom: [
    'components/**/*.{ts,tsx}',
    '!components/*/style/*.{ts,tsx}',
  ],
  transformIgnorePatterns: [
    `node_modules/(?!(${transformPackages.join('|')})/)`,
  ],

  globals: {
    'ts-jest': {
github vrk-kpa / suomifi-ui-components / jest.config.js View on Github external
'!src/**/*.d.ts',
    '!src/**/*.test.ts',
    '!src/**/*.test.tsx',
    '!**/node_modules/**',
  ],
  coverageThreshold: {
    global: {
      branches: 30,
      functions: 30,
      lines: 40,
      statements: 50,
    },
  },

  transform: {
    ...tsjPreset.transform,
    '\\.(svg)$': '/jest.transformer.js',
  },

  testMatch: tsjPreset.testMatch,
  moduleFileExtensions: tsjPreset.moduleFileExtensions,

  setupFilesAfterEnv: [require.resolve('./jest.setup.js')],

  moduleNameMapper: {
    '\\.css$': '/jest.styleMock.js',
  },
};
github microsoft / fluent-ui-react / scripts / config / jest / jest.fluent-ui-react.js View on Github external
const { defaults: tsjPreset } = require('ts-jest/presets')
const { resolveCwd } = require('just-scripts')
const path = require('path')

module.exports = {
  transform: {
    ...tsjPreset.transform,
  },
  testRegex: '/test/.*-test\\.tsx?$',
  globals: {
    'ts-jest': {
      isolatedModules: true,
      tsConfig: resolveCwd('tsconfig.json'),
      packageJson: resolveCwd('package.json'),
    },
  },
  coverageDirectory: './coverage/',
  coverageReporters: ['json', 'lcov'],
  setupFilesAfterEnv: [path.join(__dirname, 'jestSetup.fluent-ui-react.js')],
  verbose: false,
}
github speee / jsx-slack / jest.config.js View on Github external
const { defaults: tsjPreset } = require('ts-jest/presets')

module.exports = {
  collectCoverageFrom: [
    'src/**/*.js',
    'src/**/*.jsx',
    'src/**/*.ts',
    'src/**/*.tsx',
  ],
  coveragePathIgnorePatterns: ['/node_modules/', '.*\\.d\\.ts'],
  coverageThreshold: { global: { lines: 95 } },
  resetMocks: true,
  restoreMocks: true,
  testEnvironment: 'node',
  testRegex: '(/(test|__tests__)/(?![_.]).*|(\\.|/)(test|spec))\\.[jt]sx?$',
  transform: { ...tsjPreset.transform },
}