Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const typescript = require('typescript');
- const babelJest = require('babel-jest');
- const path = require('path');
- const tsConfigPath = path.resolve(__dirname, '../', 'tsconfig.json');
- const tsConfig = require(tsConfigPath);
- console.log('test');
- module.exports = {
- process(src, path, config,...rest) {
- const isTypeScript = path.endsWith('.ts') || path.endsWith('.tsx');
- const isJavaScript = path.endsWith('.js') || path.endsWith('.jsx');
- 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, config,...rest);
- }
- return src;
- },
- getCacheKey(fileData, filename) {
- // The output is always the same.
- return new Date().getTime() + 'test123';
- }
- };
Add Comment
Please, Sign In to add comment