How to use the babel-jest.process 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 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 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 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 scalable-react / scalable-react-boilerplate / config / testing / preprocessor.js View on Github external
process: function(src, filename) {
    if (!filename.match(/\.jsx?$/)) {
      return '';
    }
    return babelJest.process(
      src.replace(/import(.*)from.*\.((less)|(scss)|(svg)|(png)).*;/gi, 'let $1 = {};'
    ), filename);
  },
};
github baifendian / bfd-ui / jestPreproess.js View on Github external
process: function(src, filename) {
    return babelJest.process(src.replace(/import '.*'/gi, ''), filename);
  }
};
github atecarlos / webpack-babel-jest / index.js View on Github external
process: function(src, filename) {
		return babelJest.process(src, filename)
				.replace(/require\(\s*\'[a-zA-Z0-9\/\.\_\-\!]*\.(css|scss|less)\'\);/gm, '');
	}
};
github Lucifier129 / react-lite / jest / preprocessor.js View on Github external
process: function(src, filename) {
    if (filename.indexOf('node_modules') === -1) {
      src = babelJest.process(src, filename)
      src = webpackAlias.process(src, filename)
    }
    return src
  }
}
github blablacar / ui-library / bin / jest.preprocessor.js View on Github external
process(src, path) {
    if (moduleFileExtensions.some(extension => path.endsWith(extension))) {
      src = tsc.transpile(src, tsConfig.compilerOptions, path, [])
      src = babelJest.process(src, path, { moduleFileExtensions })
    }

    return src
  },
}

babel-jest

Jest plugin to use babel for transformation.

MIT
Latest version published 1 year ago

Package Health Score

82 / 100
Full package analysis