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

Using rewire within test #10

Open
nwhite89 opened this issue Mar 25, 2015 · 9 comments
Open

Using rewire within test #10

nwhite89 opened this issue Mar 25, 2015 · 9 comments

Comments

@nwhite89
Copy link

I'm wanting to use rewire-webpack within a Karma test is this possible? I'm wanting to run my test load in the module in which to test and run it through rewire allowing me to change specific functions which I believe rewire allows you to do?

The problem I'm getting is that it doesn't seem to be able to load the module

TypeError: webpack_require.m[module] is undefined in /Users/nickwhite/Sites/rbx_formats/test/formats/karma/src/silicon/bust.spec.js (line 84)
rewire@/Users/nickwhite/Sites/rbx_formats/test/formats/karma/src/silicon/bust.spec.js:84
[0]/WEBPACK_AMD_DEFINE_RESULT</</<@/Users/nickwhite/Sites/rbx_formats/test/formats/karma/src/silicon/bust.spec.js

be great to get an idea on this thanks

@jhnns
Copy link
Owner

jhnns commented Mar 25, 2015

Sorry, this error description is too vague. Could you create an example repository that demonstrates the problem?

@nwhite89
Copy link
Author

I can look at doing something today / tomorrow thanks @jhnns

@srph
Copy link

srph commented Apr 14, 2015

Not sure if this is related. But I'll just put it here. Anyway, I'll just create an issue if not 😉.

I'm using Karma along with Mocha and Webpack, and it doesn't seem to work although I've followed the instructions.

This is the error:

Uncaught ReferenceError: rewire is not defined

This is my karma config:

    // Webpack config
    webpack: {
      module: {
        loaders: [
          { test: /\.(js|jsx)$/, exclude: /node_modules/, loader: "babel-loader?modules=common&stage=0" }
        ]
      },
      resolve: {
        extensions: ['', '.js', '.jsx', '.es6']
      },
      devtool: 'inline-source-map',
      plugins: [new RewirePlugin()]
    },

@janusch
Copy link

janusch commented Apr 16, 2015

@srph I do not think your question is related to this issue.
Anyhow, you have to npm install rewire-webpack -save-dev and require it in your karma.conf var RewirePlugin = require('rewire-webpack');

I hope that solves yoour issue!

@jhnns
Copy link
Owner

jhnns commented Apr 22, 2015

Maybe related to #11?

@wbinnssmith
Copy link

I can confirm that I get this error when using rewire-webpack with the babel-loader (5.x or later, 4.x is just fine). My guess is that this, #12, and #11 are all the same issue.

@srph
Copy link

srph commented Apr 25, 2015

It's related. Thanks.

@jhnns
Copy link
Owner

jhnns commented Apr 27, 2015

@nwhite89 Are you using babel?

@nwhite89
Copy link
Author

No afraid not, I was basically trying to require one of my own AMD modules then within a Karma test require in the module I am wanting to test but I wanted to change a set variable within that module (which requires from another module). Purely testing purposes, I haven't tried anymore as I had to "timebox" what it was I was doing, I shall try and look at this again at some point this week @jhnns cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants