Skip to content

Importing jest/mock.js causes tests to fail #2338

@simon-abbott

Description

@simon-abbott

Describe the bug
After updating to 0.59.x our tests started failing with the error "Cannot find module './src/specs/NativeStripeSdkModule' from 'node_modules/@stripe/stripe-react-native/jest/mock.js'"

To Reproduce
Steps to reproduce the behavior:

  1. Install @stripe/stripe-react-native v0.59.0 or later
  2. Follow the Jest setup instructions
  3. Run Jest

Expected behavior
The tests should work properly

Screenshots
N/A

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
This seems to be due to the jest.mock call introduced in 976e5f6. Changing the jest.mock call from ./src/specs/NativeStripeSdkModule to ../src/specs/NativeStripeSdkModule fixed the issue for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions