lelandrichardson / lelandrichardson/enzyme-example-react-native

Cannot find module when using @providesModule

Open
#13 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Objective-C
Stars
86
Forks
26
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the React Native example with SomeButton and SomeText in separate directories, then inspect how Enzyme handles the @providesModule import and the reported module.js failure. Done means SomeText can import SomeButton by module name while running with Enzyme, or the project documents the supported limitation and workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile-dev, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.