question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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)

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
bartonhammondcommented, Jul 22, 2016

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?

1reaction
alvarombcommented, Apr 20, 2016

@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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest test runs - Cannot find module error - Stack Overflow
Your implementation looks right. But it looks like the option moduleNameWrapper was the wrong option, it's supposed to be moduleNameMapper .
Read more >
react-datepicker - npm
A simple and reusable datepicker component for React. Latest version: 4.8.0, last published: 7 months ago. Start using react-datepicker in ...
Read more >
Troubleshooting - Jest
Troubleshooting. Uh oh, something went wrong? Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why​.
Read more >
cannot find module 'elasticsearch' from 'setup-jest.js' - You.com
I'm trying to downgrade "@elastic/elasticsearch" to from "8.4.2" to version "7.6.0", but the app is not able to start, and seem the listEntities...
Read more >
[Solved]-jest.mock - Cannot find module in React test file-Reactjs
[Solved]-jest.mock - Cannot find module in React test file-Reactjs. Search. score:0. if (!window.BroadcastChannel) window.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found