tcomb-form-native: Jest tests are broken: Error: Cannot find module './datepicker' from 'index.js'

Version

Tell us which versions you are using:

  • tcomb-form-native v0.4.0
  • react-native v0.22.2

Expected behaviour

Tests should pass as they used to!

Actual behaviour

Error: Cannot find module ‘./datepicker’ from ‘index.js’

Steps to reproduce

  1. git clone git@github.com:bartonhammond/snowflake.git
  2. npm3 install
  3. npm3 test
  ✓ it if disabled and not checked, it should display square-o and text

 FAIL  src/components/__tests__/LoginForm-test.js
Runtime Error
Error: Cannot find module './datepicker' from 'index.js'
    at Loader._resolveNodeModule (/Users/barton/projects/MFV/snowflake/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:431:11)
    at Object.<anonymous> (/Users/barton/projects/MFV/snowflake/node_modules/tcomb-form-native/lib/templates/bootstrap/index.js:5:12)
    at Object.<anonymous> (/Users/barton/projects/MFV/snowflake/node_modules/tcomb-form-native/index.js:3:15)
1 test suite failed, 74 tests passed (74 total in 11 test suites, run time 7.245s)

About this issue

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

Most upvoted comments

The following seems to work w/ JEST testing!

Here is the full package.json wrt Jest setup:

 "jest": {
    "setupEnvScriptFile": "./node_modules/react-native/jestSupport/env.js",
    "haste": {
      "defaultPlatform": "ios",
      "platforms": [
        "ios",
        "android"
      ],
      "providesModuleNodeModules": [
        "react-native"
      ]
    },
    "testPathIgnorePatterns": [
      "/node_modules/"
    ],
    "testFileExtensions": [
      "es6",
      "js"
    ],
    "moduleFileExtensions": [
      "js",
      "json",
      "es6",
      "ios.js"   <<<<<<<<<<<<<<<<<<<<<<<< this makes it work!
    ],
    "unmockedModulePathPatterns": [
      "react",
      "react-addons-test-utils",
      "react-native-router-flux",
      "promise",
      "source-map",
      "key-mirror",
      "immutable",
      "fetch",
      "redux",
      "redux-thunk",
      "fbjs"
    ],
    "collectCoverage": false,
    "verbose": true
  },

Would you like a PR w/ a note in the README?

@bartonhammond I’ve opened a SO question about this http://stackoverflow.com/questions/36479136/test-platform-specific-extension-code-for-react-native

Have you managed to test platform-specific code under snowflake?