jest: Invariant Violation: Module name prefixes should've been stripped by the native side but wasn't for RCTStatusBarManager

Do you want to request a feature or report a bug? Bug

What is the current behavior?

Test suite failed to run

    Invariant Violation: Module name prefixes should've been stripped by the native side but wasn't for RCTStatusBarManager

      at invariant (node_modules/fbjs/lib/invariant.js:38:15)
      at genModule (node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js:35:1)
      at node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js:125:10
      at Array.forEach (native)
      at Object.<anonymous> (node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js:122:39)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can npm install and npm test.

npm install jest babel-jest jest-react-native

jest --no-cache --coverage

"jest": {
    "preset": "jest-react-native"
  },

What is the expected behavior? it should actually test

Run Jest again with --debug and provide the full configuration it prints. Please mention your node and npm version and operating system.

> jest --no-cache --coverage --debug

jest version = 16.0.1
test framework = jasmine2
config = {
  "haste": {
    "defaultPlatform": "ios",
    "platforms": [
      "android",
      "ios"
    ],
    "providesModuleNodeModules": [
      "react",
      "react-native"
    ]
  },
  "moduleNameMapper": [
    [
      "^image![a-zA-Z0-9$_-]+$",
      "GlobalImageStub"
    ],
    [
      "^[./a-zA-Z0-9$_-]+\\.(bmp|gif|jpg|jpeg|png|psd|svg|webp)$",
      "RelativeImageStub"
    ]
  ],
  "modulePathIgnorePatterns": [
    "/Users/chirag/Desktop/qsi/comlink/node_modules/react-native/Libraries/react-native/",
    "/Users/chirag/Desktop/qsi/comlink/node_modules/react-native/packager/"
  ],
  "preprocessorIgnorePatterns": [
    "node_modules/(?!(jest-)?react-native|react-clone-referenced-element)"
  ],
  "setupFiles": [
    "/Users/chirag/Desktop/qsi/comlink/node_modules/babel-polyfill/lib/index.js",
    "/Users/chirag/Desktop/qsi/comlink/node_modules/jest-react-native/build/setup.js"
  ],
  "testEnvironment": "/Users/chirag/Desktop/qsi/comlink/node_modules/jest-environment-node/build/index.js",
  "preset": "jest-react-native",
  "rootDir": "/Users/chirag/Desktop/qsi/comlink",
  "name": "-Users-chirag-Desktop-qsi-comlink",
  "testRunner": "/Users/chirag/Desktop/qsi/comlink/node_modules/jest-jasmine2/build/index.js",
  "scriptPreprocessor": "/Users/chirag/Desktop/qsi/comlink/node_modules/babel-jest/build/index.js",
  "usesBabelJest": true,
  "automock": false,
  "bail": false,
  "browser": false,
  "cacheDirectory": "/var/folders/6j/rqjprs4n687cstlp6rxgnlk40000gn/T/jest",
  "clearMocks": false,
  "coveragePathIgnorePatterns": [
    "/node_modules/"
  ],
  "coverageReporters": [
    "json",
    "text",
    "lcov",
    "clover"
  ],
  "globals": {},
  "mocksPattern": "__mocks__",
  "moduleDirectories": [
    "node_modules"
  ],
  "moduleFileExtensions": [
    "js",
    "json",
    "jsx",
    "node"
  ],
  "noStackTrace": false,
  "notify": false,
  "resetModules": false,
  "testPathDirs": [
    "/Users/chirag/Desktop/qsi/comlink"
  ],
  "testPathIgnorePatterns": [
    "/node_modules/"
  ],
  "testRegex": "(/__tests__/.*|\\.(test|spec))\\.jsx?$",
  "testURL": "about:blank",
  "timers": "real",
  "useStderr": false,
  "verbose": null,
  "watch": false,
  "collectCoverage": true,
  "cache": false,
  "watchman": true,
  "testcheckOptions": {
    "times": 100,
    "maxSize": 200
  }
}

node v6.4.0 npm v3.10.3

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 20 (5 by maintainers)

Most upvoted comments

try jest-react-native@test and jest@test. We’ll publish a new tagged release soon.

This bug happens also with current version 16.0.2 on a newly created test application.

react-native init testApp
cd testApp
jest

$ cat package.json 
{
  "name": "********",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "15.3.2",
    "react-native": "0.36.0"
  },
  "jest": {
    "preset": "jest-react-native"
  },
  "devDependencies": {
    "babel-jest": "16.0.0",
    "babel-preset-react-native": "1.9.0",
    "jest": "16.0.2",
    "jest-react-native": "16.0.0",
    "react-test-renderer": "15.3.2"
  }
}

@tigerohuang just change the version to test like so: "jest-react-native": "test",

The latest version of jest-react-native should work just fine. Simply install the 16.1.0 version of it.

@edvinerikson ,how to “update to jest-react-native@test and jest@test”, my package.json is “devDependencies”: { “babel-jest”: “16.0.0”, “babel-preset-react-native”: “1.9.0”, “jest”: “16.0.2”, “jest-react-native”: “16.1.0”, “react-test-renderer”: “15.3.2” }

@edvinerikson cheers lack of understanding on my side sorry re cpojer’s comment

I’m still having this issue after updating versions. “react”: “15.3.2”, “react-native”: “^0.36.1”,

jest": “^16.0.2”, “jest-react-native”: “^16.0.0”,

Last release was 13 days ago, is there a workaround other than using an earlier version of react?

@cpojer

We’ll publish a new tagged release soon.

using RN master branch as of today. cc @cpojer