Skip to content

Cannot find module when using @providesModule #13

@nicnocquee

Description

@nicnocquee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions