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

Cannot find module './create_spy' from 'jasmine_light.js' #5629

Closed
ShintaroNippon opened this issue Feb 21, 2018 · 7 comments
Closed

Cannot find module './create_spy' from 'jasmine_light.js' #5629

ShintaroNippon opened this issue Feb 21, 2018 · 7 comments

Comments

@ShintaroNippon
Copy link

ShintaroNippon commented Feb 21, 2018

I'm getting this error with these configurations:
at
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:194:17)
node -v = v8.9.4

package.json

{
  "name": "frontend",
  "jestWebpackResolver": {
    "silent": true,
    "webpackConfig": "./tests/webpack.config.js"
  },
  "private": true,
  "version": "3.0.0-alpha.1",
  "description": "Zaask FrontEnd",
  "main": "src/app/index.js",
  "scripts": {
    "clean": "rimraf dist/*",
    "copy": "copyfiles -f ./src/app/index.html ./dist && copyfiles -u 1 \"./src/assets/**\" ./dist",
    "dist": "npm run clean && npm run copy && webpack --progress --bail --env dist -p",
    "lint": "./node_modules/.bin/eslint ./src/app/",
    "serve:dev": "webpack-dev-server --env dev",
    "serve:dist": "webpack-dev-server --env dist -p --progress",
    "start": "npm run serve:dev",
    "test": "NODE_ENV=dev jest"
  },
  "repository": "",
  "author": "Carlos Vieira",
  "devDependencies": {
    "babel-core": "^6.25.0",
    "babel-loader": "~6.4.0",
    "babel-polyfill": "~6.23.0",
    "babel-preset-es2015": "~6.24.0",
    "babel-preset-react": "~6.24.0",
    "babel-preset-stage-2": "~6.24.0",
    "copy-webpack-plugin": "^4.0.0",
    "copyfiles": "^1.0.0",
    "css-loader": "^0.26.4",
    "eslint": "^4.0.0",
    "eslint-plugin-react": "^7.0.0",
    "file-loader": "^0.9.0",
    "jest": "^22.4.0",
    "jquery": "^3.3.1",
    "resolve-url-loader": "^2.2.1",
    "rimraf": "^2.5.2",
    "sass-loader": "^3.2.3",
    "source-map-loader": "^0.2.1",
    "style-loader": "^0.13.2",
    "tether": "^1.4.3",
    "url-loader": "^0.5.9",
    "webpack-dev-server": "~2.4.0"
  },
  "dependencies": {
    "ajv": "^6.1.1",
    "autoprefixer": "^7.2.3",
    "axios": "^0.18.0",
    "babel-jest": "^22.4.0",
    "bootstrap": "^4.0.0",
    "child_process": "^1.0.2",
    "cssnano": "^3.10.0",
    "extract-text-webpack-plugin": "^3.0.2",
    "fs": "0.0.1-security",
    "jest-webpack-alias": "^3.3.3",
    "jest-webpack-resolver": "^0.2.0",
    "js-cookie": "~2.1.0",
    "jsdom": "^11.6.2",
    "less": "^2.7.3",
    "less-loader": "^4.0.5",
    "location": "0.0.1",
    "navigator": "^1.0.1",
    "node-sass": "^3.13.1",
    "normalize-scss": "~7.0.0",
    "popper.js": "^1.12.9",
    "postcss-cssnext": "^3.0.2",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.9",
    "precss": "^2.0.0",
    "prop-types": "~15.5.0",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-redux": "~5.0.0",
    "react-router": "~4.1.0",
    "react-router-dom": "~4.1.0",
    "react-transition-group": "~1.1.0",
    "redux": "~3.6.0",
    "redux-thunk": "~2.2.0",
    "regenerator-runtime": "^0.11.1",
    "resolve": "^1.5.0",
    "sugarss": "^1.0.1",
    "utils": "^0.3.1",
    "webpack": "^3.11.0"
  },
  "jest": {
    "haste": {
      "providesModuleNodeModules": [
        "node_modules"
      ]
    },
    "moduleDirectories": [
      "node_modules"
    ],
    "transform": {
      ".*": "./tests/preprocessor.js"
    },
    "modulePaths": [
      "src"
    ],
    "resolver": "jest-webpack-resolver",
    "collectCoverageFrom": [
      "**/*.{js,jsx}",
      "!**/node_modules/**",
      "!**/vendor/**"
    ],
    "testPathIgnorePatterns": [
      "<rootDir>/node_modules/"
    ]
  }
}
```
`

webpackconfig in other folder
`var webpack = require('webpack');


module.exports = {
  module: {
    loaders: [
      {exclude: ['node_modules'], loader: 'babel', test: /\.jsx?$/},
      {loader: 'style-loader!css-loader', test: /\.css$/},
      {loader: 'url-loader', test: /\.gif$/},
      {loader: 'file-loader', test: /\.(ttf|eot|svg)$/},
    ],
  },
  resolve: {
    extensions: ['', 'js', 'jsx'],
    modules: [
      'node_modules',
      'bower_components',
      'shared',
      '/shared/vendor/modules',
    ],
  },
};`

preprocessor

`var babelJest = require('babel-jest');
require('babel-register'); // support ES6 'import' statements 
var webpackAlias = require('jest-webpack-alias');
 
module.exports = {
  process: function(src, filename, ...rest) {
    if (filename.indexOf('node_modules') === -1) {
      src = babelJest.process(src, filename, ...rest);
      src = webpackAlias.process(src, filename, ...rest);
    }
    return src;
  }
};`


Can someone please help me on this... im blocked
Thanks in advance
Carlos Vieira
@cpojer
Copy link
Member

cpojer commented Feb 21, 2018

rm your node modules, upgrade Jest, and reinstall with Yarn.

Please note this issue tracker is not a help forum (as stated in issue template).

We recommend using StackOverflow where there are community incentives to help others or our Discord channel for questions.

You'll find more on the Jest help page.

@cpojer cpojer closed this as completed Feb 21, 2018
@ShintaroNippon
Copy link
Author

I tried remove all node modules and install with yarn or npm
same issue
thanks
carlos vieira

@ShintaroNippon
Copy link
Author

i rm node modules and update to 22 jest but still have the error
thanks

@thymikee
Copy link
Collaborator

@ShintaroNippon this is a duplicate of #4025. You'll find a workaround there

@ShintaroNippon
Copy link
Author

thanks.. i tried to resolve in that way but without sucess
i will try to change the package json as equal as in that 4025

many thanks
carlos vieira

@ShintaroNippon
Copy link
Author

i have changed the configuration jest to

"jest": {
    "transform": {
      ".*": "./tests/preprocessor.js"
    },
    "modulePaths": [
      "src"
    ],
  "testPathIgnorePatterns": [
    "/node_modules/",
    "/vendor"
],
"testRegex": "\\.spec\\.js"
  }

but then im getting an error

FAIL tests/state-functions.spec.js
● Test suite failed to run

Your test suite must contain at least one test.

  at node_modules/jest-cli/build/test_scheduler.js:108:22

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants