plasticine / inject-loader

💉📦 A Webpack loader for injecting code into modules via their dependencies.
https://www.npmjs.com/package/inject-loader
MIT License
482 stars 47 forks source link

Work with Jest #55

Closed rmartins90 closed 6 years ago

rmartins90 commented 6 years ago

Can't get this working with Jest. Got a

Cannot find module 'inject-loader!...

plasticine commented 6 years ago

@rmartins90 Yep, that’s expected — inject-loader only works with Webpack.

tristanpendergrass commented 6 years ago

I'm having this issue too.

@plasticine Jest is not an alternative to Webpack but it is an alternative to Karma so did you mean "only works with Karma"?

plasticine commented 6 years ago

Jest is not an alternative to Webpack but it is an alternative to Karma so did you mean "only works with Karma"?

@tristanpendergrass Nope, that’s not really what I meant, but I can see why that was perhaps not as clear as it could’ve been.

You can use whatever test runner you want, but your test code has to be compiled by Webpack before passing it to the runner, thus @rmartins90’s issue above with the inline loader syntax, which is specific to Webpack .

inject-loader requires roughly the following;

1) Your test code  -->  2) Webpack  --> 3) Some test runner

How you organise this workflow is entirely up to you. I suspect it would not be too hard at all to integrate with Jest if you wanted — https://facebook.github.io/jest/docs/en/webpack.html