Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
// @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,
});
/* eslint-disable import/no-extraneous-dependencies */
module.exports = require('babel-jest').createTransformer({
rootMode: 'upward',
})
// 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"],
});
/* eslint-disable import/no-extraneous-dependencies */
module.exports = require('babel-jest').createTransformer({
rootMode: 'upward',
})
const babelJest = require('babel-jest');
module.exports = babelJest.createTransformer({
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
],
[
'@babel/preset-react',
{
pragma: 'toHtmlString',
pragmaFrag: 'toHtmlString.Fragment'
}
]
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}`);
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 }]
]
const babelJest = require('babel-jest');
const babelConfig = require('../babel/config');
babelConfig.plugins.push('@babel/plugin-transform-modules-commonjs');
module.exports = babelJest.createTransformer(babelConfig);
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);