Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
},
};
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;
}
}
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;
},
};
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
},
}
process: function(src, filename) {
if (!filename.match(/\.jsx?$/)) {
return '';
}
return babelJest.process(
src.replace(/import(.*)from.*\.((less)|(scss)|(svg)|(png)).*;/gi, 'let $1 = {};'
), filename);
},
};
process: function(src, filename) {
return babelJest.process(src.replace(/import '.*'/gi, ''), filename);
}
};
process: function(src, filename) {
return babelJest.process(src, filename)
.replace(/require\(\s*\'[a-zA-Z0-9\/\.\_\-\!]*\.(css|scss|less)\'\);/gm, '');
}
};
process: function(src, filename) {
if (filename.indexOf('node_modules') === -1) {
src = babelJest.process(src, filename)
src = webpackAlias.process(src, filename)
}
return src
}
}
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
},
}