Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest mocks have their paths specified incorrectly #338

Closed
no23reason opened this issue Jun 27, 2018 · 1 comment
Closed

Jest mocks have their paths specified incorrectly #338

no23reason opened this issue Jun 27, 2018 · 1 comment
Labels

Comments

@no23reason
Copy link

Description

After the Jest mock files introduced in #303 the tests fail on our VSTS Hosted build agent with the following error:

Validation Error:
Module .\node_modules\appcenter\test\AppCenterMock.js in the setupFiles option was not found.
<rootDir> is: D:_work\1\s\src\CustomerDesk.MobileApp
Configuration Documentation:
https://facebook.github.io/jest/docs/configuration.html

The problem seems to be in the path specification of the mock files that is added during the installation into the package.json by appcenter:

"jest": {
    "setupFiles": [
      "./node_modules/appcenter/test/AppCenterMock.js",
      "./node_modules/appcenter-analytics/test/AppCenterAnalyticsMock.js",
      "./node_modules/appcenter-crashes/test/AppCenterCrashesMock.js"
    ]
  },

If I patch the file using sed right after the installation finishes (and before we run the tests) to look like this:

"jest": {
    "setupFiles": [
      "<rootDir>/node_modules/appcenter/test/AppCenterMock.js",
      "<rootDir>/node_modules/appcenter-analytics/test/AppCenterAnalyticsMock.js",
      "<rootDir>/node_modules/appcenter-crashes/test/AppCenterCrashesMock.js"
    ]
  },

everything works fine. Could the file specifications use the <rootDir> by default to ensure this works everywhere?

Details

  1. Which SDK version are you using?
    • 1.6.0
  2. Which OS version did you experience the issue on?
    • Windows (specifically Hosted VS2017 VSTS build agent)
  3. What device version did you see this error on? Were you using an emulator or a physical device?
    • N/A
  4. What third party libraries are you using?
    • jest
  5. Run the following command and paste the output below: react-native info

Environment:
OS: Windows 10
Node: 10.0.0
Yarn: 1.6.0
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4

  1. If you're developing for React Native iOS, run the following command and paste the output below: pod --version
    N/A

  2. Please enable verbose logging for your app using [MSAppCenter setLogLevel: MSLogLevelVerbose]; before your call to [AppCenterReactNative register]; (or any other SDK registration). For Android, use AppCenter.setLogLevel(android.util.Log.VERBOSE); before your SoLoader.init call. Include the logs here:
    N/A, it is a build issue

@no23reason no23reason changed the title Jest mocks have their paths specified wrong Jest mocks have their paths specified incorrectly Jun 27, 2018
@dhei dhei added the bug label Jun 27, 2018
@dhei
Copy link
Member

dhei commented Jul 23, 2018

Hey @no23reason,

This issue has been fixed in #340 and it is now released in v1.7.0 of this SDK. Thanks for reporting this issue to us, we really appreciate it. I am closing this issue now.

@dhei dhei closed this as completed Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants