vendredi 26 août 2016

TypeError while performing Unit test of Reactnative Component + Jest

I have done the setup and now I am writing a simple unit test but always getting error.Also on jest the Documentation for reactNative is for taking snapshot.Please help where I am wrong weather i should mock dimensions in my test file or I am missing any plugin.

I am getting following error :

enter image description here

Here is my code.

MyScreen-test.js

enter image description here

ScreenOne.js enter image description here

    Package.Json 
    {
      "name": "***App",
      "version": "0.0.1",
      "private": true,
      "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "rm -rf ./node_modules/jest-cli/.haste_cache && jest"
      },
      "dependencies": {
         "react": "15.2.0",
        "react-native": "0.30.0",
       },
      "devDependencies": {
        "babel-core": "^6.13.2",
        "babel-jest": "^14.1.0",
        "jest-cli": "^14.1.0",
        "react-addons-test-utils": "^15.3.1",
        "react-native-mock": "^0.2.6",
        "react-shallow-renderer-helpers": "^2.0.2"
      },
      "jest": {
        "scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
        "testFileExtensions": [
          "js"
        ],
        "moduleFileExtensions": [
          "js",
          "json",
          "es6"
        ],
        "unmockedModulePathPatterns": [
          "<rootDir>/node_modules/react",
          "<rootDir>/node_modules/react-native",
          "<rootDir>/node_modules/fbjs"
        ],
        "verbose": true,
        "collectCoverage": true,
        "testPathIgnorePatterns": [
          "/node_modules/",
          "packager/react-packager/src/Activity/"
        ]
      }
    }

Aucun commentaire:

Enregistrer un commentaire