jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.08k stars 6.44k forks source link

Using Bower #195

Closed austbot closed 8 years ago

austbot commented 9 years ago

Lets say I have a project that uses bower, grunt, bowerify(with shim) and since I love Jest so much I want to test with that. How in the world do I get jest to see my browserify shim modules when it runs tests. I use grunt, to kick off the npm test command. Here is my package.json file.

"browser": {
    "jquery": "./bower_components/jquery/dist/jquery.js",
    "foundation": "./bower_components/foundation/js/foundation/foundation.js",
    "fastclick": "./bower_components/fastclick/lib/fastclick.js",
    "greensock-tm": "./bower_components/gsap/src/uncompressed/TweenMax.js",
    "greensock-css": "./bower_components/gsap/src/uncompressed/plugins/CSSPlugin.js",
    "greensock-time": "./bower_components/gsap/src/uncompressed/TimelineMax.js",
    "scrollmagic": "./bower_components/ScrollMagic/js/jquery.scrollmagic.js",
    "handlebars": "./bower_components/handlebars/handlebars.runtime.js"
  },
  "browserify-shim": {
    "jquery": "$",
    "greensock-css": "CSSPlugin",
    "fastclick": "FastClick",
    "greensock-tm": "TweenMax",
    "greensock-time": "TimelineMax",
    "scrollmagic": "ScrollMagic",
    "foundation": "foundation",
    "handlebars": "Handlebars"
  },
  "browserify": {
    "transform": [
      "browserify-shim"
    ]
  },
fddayan commented 9 years ago

Hi, were you able to run jest with that setup ?

ghost commented 9 years ago

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

cpojer commented 8 years ago

There is a moduleNameMapper option now that is made for this use-case. It should work well in the 0.9 release of Jest.

brandonros commented 6 years ago

Can an example on how to use moduleNameMapper with what would otherwise be a list of bower_components be shared please?

github-actions[bot] commented 3 years ago

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.