How to use the babel-jest.createTransformer function in babel-jest

To help you get started, we’ve selected a few babel-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 umijs / umi / packages / umi-test / src / transformers / jsTransformer.js View on Github external
import babelJest from 'babel-jest';
import { dirname } from 'path';
import { compatDirname } from 'umi-utils';

const cwd = process.cwd();

module.exports = babelJest.createTransformer({
  presets: [
    require.resolve('@babel/preset-typescript'),
    [
      require.resolve('babel-preset-umi'),
      {
        transformRuntime: false,
        // ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
      },
    ],
  ],
  plugins: [
    [
      require.resolve('babel-plugin-module-resolver'),
      {
        alias: {
          // Projects don't need to install react, react-dom and enzyme
github makuga01 / dnsFookup / FE / node_modules / react-scripts / config / jest / babelTransform.js View on Github external
// @remove-file-on-eject
/**
 * Copyright (c) 2014-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
'use strict';

const babelJest = require('babel-jest');

module.exports = babelJest.createTransformer({
  presets: [require.resolve('babel-preset-react-app')],
  babelrc: false,
  configFile: false,
});
github triplecanopy / b-ber / packages / b-ber-grammar-gallery / jest-transform-upward.js View on Github external
/* eslint-disable import/no-extraneous-dependencies */
module.exports = require('babel-jest').createTransformer({
  rootMode: 'upward',
})
github Caltech-IPAC / firefly / __jest__ / jest.transform.js View on Github external
// Custom Jest transform implementation that wraps babel-jest and injects our
// babel presets, so we don't have to use .babelrc.

module.exports = require('babel-jest').createTransformer({
  presets: ["env", "react", "stage-3"],
});
github triplecanopy / b-ber / packages / b-ber-grammar-attributes / jest-transform-upward.js View on Github external
/* eslint-disable import/no-extraneous-dependencies */
module.exports = require('babel-jest').createTransformer({
  rootMode: 'upward',
})
github preactjs / preact-integrations / tests / babelTransformer.js View on Github external
const babelJest = require('babel-jest');

module.exports = babelJest.createTransformer({
	presets: [
		[
			'@babel/preset-env',
			{
				targets: {
					node: 'current'
				}
			}
		],
		[
			'@babel/preset-react',
			{
				pragma: 'toHtmlString',
				pragmaFrag: 'toHtmlString.Fragment'
			}
		]
github react-component / rc-tools / scripts / jestPreprocessor.js View on Github external
const path = require('path');
const chalk = require('chalk');
const { createTransformer: babelTransFormer } = require('babel-jest');
const { createTransformer: tsTransFormer } = require('ts-jest');
const getBabelCommonConfig = require('../lib/getBabelCommonConfig');

const tsJest = tsTransFormer({
  tsConfig: path.join(__dirname, '../lib/tests/tsconfig.test.json'),
});
const babelJest = babelTransFormer(getBabelCommonConfig());

module.exports = {
  process(src, filePath) {
    const isTypeScript = filePath.endsWith('.ts') || filePath.endsWith('.tsx');
    const isJavaScript = filePath.endsWith('.js') || filePath.endsWith('.jsx');

    if (isTypeScript) {
      src = tsJest.process(src, filePath, { moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'] });
    } else if (isJavaScript) {
      src = babelJest.process(src, filePath, { moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'] });
    } else {
      console.log(
        chalk.red('File not match type:'),
        filePath
      );
      throw new Error(`File not match type: ${filePath}`);
github infernojs / inferno / jest.ts.transform.js View on Github external
const typescript = require('typescript');
const babelJest = require('babel-jest').createTransformer({
  babelrc: false,
  presets: [
    ["@babel/preset-env",
      {
        "modules": "commonjs",
        "loose": true,
        "targets": {
          "node": "current"
        }
      }
    ]
  ],
  plugins: [
    ["babel-plugin-inferno", {"imports": true}],
    ["@babel/plugin-proposal-class-properties", { "loose": true }]
  ]
github JeromeLin / zarm-web / scripts / jest / preprocessor.js View on Github external
const babelJest = require('babel-jest');
const babelConfig = require('../babel/config');

babelConfig.plugins.push('@babel/plugin-transform-modules-commonjs');

module.exports = babelJest.createTransformer(babelConfig);
github vazco / uniforms / scripts / transform.js View on Github external
const fs = require('fs');
const jest = require('babel-jest');
const path = require('path');

const configPath = path.resolve(__dirname, '..', '.babelrc.json');
const config = JSON.parse(fs.readFileSync(configPath));

module.exports = jest.createTransformer(config);

babel-jest

Jest plugin to use babel for transformation.

MIT
Latest version published 1 year ago

Package Health Score

82 / 100
Full package analysis