How to mock react native 3rd party module "rn-sliding-up-panel'

Viewed 180

I am trying to running yarn test in my new react native init project with additions 3rd party modules in my project, such as rn-sliding-up-panel

in my App.js just look like this:

import React from 'react';
import {View, Button, Text} from 'react-native';

import SlidingUpPanel from 'rn-sliding-up-panel';

const styles = {
  container: {
    flex: 1,
    backgroundColor: 'white',
    alignItems: 'center',
    justifyContent: 'center'
  }
}

class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Button title='Show panel' onPress={() => this._panel.show()} />
        <SlidingUpPanel ref={c => this._panel = c}>
          <View style={styles.container}>
            <Text>Here is the content inside panel</Text>
            <Button title='Hide' onPress={() => this._panel.hide()} />
          </View>
        </SlidingUpPanel>
      </View>
    )
  }
}

and somehow after I run yarn test it fails with:

 ● Test suite failed to run

/The Codes/ssa-mobile/node_modules/rn-sliding-up-panel/SlidingUpPanel.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import React from 'react'
                                                                                                ^^^^^

SyntaxError: Unexpected identifier

is there a way to pass the yarn test jest with addition this 3rd party module?.

noted: the test work perfectly before I using this 'rn-sliding-up-panel' module

0 Answers
Related