Convert Mocha and Chai to Jest
$ jscodeshift <path> -t assert-to-expect.js
$ jscodeshift <path> -t mocha-to-jest.js
/** | |
* Copyright (c) 2019 Paul Armstrong | |
*/ | |
import * as Theme from '../theme'; | |
import React from 'react'; | |
import { StyleProp, StyleSheet, TouchableOpacity, TouchableOpacityProps, View, ViewStyle } from 'react-native'; | |
interface Props { | |
children: React.ReactElement; | |
disabled?: boolean; |
export default function(target) { | |
const originalMethods = { | |
UNSAFE_componentWillMount: target.prototype.UNSAFE_componentWillMount || noop, | |
componentDidMount: target.prototype.componentDidMount || noop, | |
UNSAFE_componentWillUpdate: target.prototype.UNSAFE_componentWillUpdate || noop, | |
componentDidUpdate: target.prototype.componentDidUpdate || noop, | |
componentWillUnmount: target.prototype.componentWillUnmount || noop | |
}; | |
target.prototype.UNSAFE_componentWillMount = function(...args) { |
define(['modules/foo'], function (foo) { | |
describe('test foo', function () { | |
// ... | |
}); | |
}); |
$ jscodeshift <path> -t assert-to-expect.js
$ jscodeshift <path> -t mocha-to-jest.js
const HeartIcon = (props) => React.createElement('svg', { | |
...props, | |
dangerouslySetInnerHTML: { __html: '<g><path d="M38.723 12c-7.187 0-11.16 7.306-11.723 8.131C26.437 19.306 22.504 12 15.277 12 8.791 12 3.533 18.163 3.533 24.647 3.533 39.964 21.891 55.907 27 56c5.109-.093 23.467-16.036 23.467-31.353C50.467 18.163 45.209 12 38.723 12z"></path></g>' }, | |
viewBox: '0 0 54 72' | |
}); |
function memorySizeOf(obj) { | |
var bytes = 0; | |
function sizeOf(obj) { | |
if(obj !== null && obj !== undefined) { | |
switch(typeof obj) { | |
case 'number': | |
bytes += 8; | |
break; | |
case 'string': |
function memorySizeOf(obj) { | |
var bytes = 0; | |
function sizeOf(obj) { | |
if(obj !== null && obj !== undefined) { | |
switch(typeof obj) { | |
case 'number': | |
bytes += 8; | |
break; | |
case 'string': |
const FetchStatus = { | |
FAILED: 'failed', | |
LOADED: 'loaded', | |
LOADING: 'loading', | |
NONE: 'none' | |
}; | |
class LoadingRenderer extends React.Component { | |
static propTypes = { | |
fetchStatus: React.PropTypes.oneOf(Object.values(FetchStatus)).isRequired, |
I hereby claim:
To claim this, I am signing this object:
const state = { | |
timelines: { | |
home: { | |
tweets: [ | |
'123', | |
'456', | |
'789', | |
'012' | |
] | |
} |