Skip to content

Instantly share code, notes, and snippets.

@mateuszsokola
Last active October 11, 2017 21:01
Show Gist options
  • Save mateuszsokola/f51f0a8c1d6ade78de4935a64a71d6d1 to your computer and use it in GitHub Desktop.
Save mateuszsokola/f51f0a8c1d6ade78de4935a64a71d6d1 to your computer and use it in GitHub Desktop.
/**
* Transpiles TypeScript to JavaScript code.
*
* @link https://github.com/facebook/jest/blob/master/examples/typescript/preprocessor.js
* @copyright 2004-present Facebook. All Rights Reserved.
*/
const tsc = require('typescript');
const tsConfig = require('./tsconfig.json');
module.exports = {
process(src, path) {
if (path.endsWith('.ts') || path.endsWith('.tsx') || path.endsWith('.js')) {
return tsc.transpile(src, tsConfig.compilerOptions, path, []);
}
return src;
},
};
/**
* Defines the React 16 Adapter for Enzyme.
*
* @link http://airbnb.io/enzyme/docs/installation/#working-with-react-16
* @copyright 2017 Airbnb, Inc.
*/
const enzyme = require("enzyme");
const Adapter = require("enzyme-adapter-react-16");
enzyme.configure({ adapter: new Adapter() });
/**
* Get rids of the missing requestAnimationFrame polyfill warning.
*
* @link https://reactjs.org/docs/javascript-environment-requirements.html
* @copyright 2004-present Facebook. All Rights Reserved.
*/
global.requestAnimationFrame = function(callback) {
setTimeout(callback, 0);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment