enzyme-example-react-native icon indicating copy to clipboard operation
enzyme-example-react-native copied to clipboard

Cannot find module when using @providesModule

Open nicnocquee opened this issue 9 years ago • 0 comments

I'm trying to use enzyme following this example for my RN project.

I have two components, say SomeButton and SomeText and they are not in the same directory.

/**
* @providesModule SomeButton
*/

'use strict'

import React from 'react'
import {
  View
} from 'react-native'

module.exports = () => {
  return (
    <View></View>
  )
}
/**
* @providesModule SomeText
*/

'use strict'

import React from 'react'
import {
  View
} from 'react-native'
import SomeButton from 'SomeButton'

module.exports = () => {
  return (
    <View>
      <SomeButton />
   </View>
  )
}

I use @providesModule so that I can just import a component without specifying the path. But this doesn't work with enzyme.

module.js:442
    throw err;
    ^

Error: Cannot find module 'SomeButton'

Any idea how to solve this? aside from not using @providesModule

nicnocquee avatar Jun 29 '16 14:06 nicnocquee