How to use babel-jest - 10 common examples

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 jaydp17 / series-notifier-serverless / test / jest.preprocessor.js View on Github external
compilerOptions: {
          module: tsc.ModuleKind.ES2015,
          target: tsc.ScriptTarget.ESNext,
          moduleResolution: tsc.ModuleResolutionKind.Node,
          allowSyntheticDefaultImports: true,
        },
        fileName: path,
      });
      src = src.outputText;

      // update the path so babel can try and process the output
      path = path.substr(0, path.lastIndexOf('.')) + (isTs ? '.js' : '.jsx') || path;
    }

    if (path.endsWith('.js') || path.endsWith('.jsx')) {
      src = babelJest.process(src, path);
    }
    // console.log('src', src);
    return src;
  },
};
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 peerplays-network / peerplays-core-gui / src / __tests__ / __tests__ / jest-preprocessor.js View on Github external
process: function(src, path) {
    src = babel_jest.process(src, path)
    // CoffeeScript files can be .coffee, .litcoffee, or .coffee.md
    if (coffee.helpers.isCoffee(path)) {
      return coffee.compile(src, {'bare': true});
    }
    return src;
  }
}
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 lozinsky / typescript-babel-jest / source / index.js View on Github external
if (isTypeScript) {
            src = typescript.transpile(
                src,
                tsConfig.compilerOptions,
                path,
                [],
            );
        }

        if (isJavaScript || isTypeScript) {
            // babel-jest hack for transpile src without file
            const fileName = isJavaScript
                ? path
                : 'file.js';

            src = babelJest.process(
                src,
                fileName,
            );
        }

        return src;
    },
};
github AdaptiveConsulting / ReactiveTraderCloud / src / client / preprocessor.js View on Github external
process(src, path) {
    if (path.endsWith('.ts') || path.endsWith('.tsx')) {
      return tsc.transpile(src, tsConfig.compilerOptions, path, [])
        .replace(/^(require|import).*\.scss.*;$/gm, '') // remove scss imports
    }
    if (path.endsWith('.js') || path.endsWith('.jsx')) {
      return babelJest.process(src, path)
        .replace(/^(require|import).*\.scss.*;$/gm, '') // remove scss imports
    }
    return src
  },
}
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'
			}
		]

babel-jest

Jest plugin to use babel for transformation.

MIT
Latest version published 1 year ago

Package Health Score

76 / 100
Full package analysis