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

rewire integration #91

Closed
GiladShoham opened this issue Mar 27, 2017 · 7 comments
Closed

rewire integration #91

GiladShoham opened this issue Mar 27, 2017 · 7 comments

Comments

@GiladShoham
Copy link
Contributor

Hi,
Would be great to integrate rewire (as a way to test private functions / vars)
It's a bit tricky with the es6 import/export and mocha webpack.

This might work:
https://www.npmjs.com/package/rewire-webpack
Or maybe this
https://github.com/speedskater/babel-plugin-rewire

What do you think?
Thanks.

@larixer
Copy link
Member

larixer commented Mar 27, 2017

Hi Gilad,

The first link will not work, because it doesn't support Webpack 2. The babel plugin might work, but need to check this. It will be certainly tricky for ES6. Generally speaking if you need private function testing / private vars testing - you are doing something wrong, but I understand there might be exceptions and scenarios where this approach is valid...

@GiladShoham
Copy link
Contributor Author

Hi,
Thanks, for the quick reply.

I have a service which fetches data from DB then do some manipulation.
The manipulation part is on a private function.
I want to test only this part (until I'll implement the full test with the DB fetching).

But even without this, there is always exceptions:)

By the way, I still haven't upgrade to webpack 2, so it might work:)

@larixer
Copy link
Member

larixer commented Mar 27, 2017

Hi,

Maybe approach like that in this answer might be more preferable (rewire seems as overkill for this purpose):
http://stackoverflow.com/questions/22097603/unit-testing-of-private-functions-with-mocha-and-node-js

@larixer
Copy link
Member

larixer commented Mar 27, 2017

This whole topic is controversal however :) If one would investigate compatibility of rewire with ES6 and if it is compatible indeed, then I think it's fine to add rewire to this kit as one of the approaches to test private functions.

@GiladShoham
Copy link
Contributor Author

Ok,
I'll try to play a little bit with it.
If it will work I'll let you know.
If you do it before, just update the issue:)

@larixer
Copy link
Member

larixer commented Mar 27, 2017

@GiladShoham Sure, thank you Gilad!

@larixer
Copy link
Member

larixer commented May 3, 2017

Closing this, since not much activity happening and no clear plans when if we will work on it. Please reopen if you have another thoughts.

@larixer larixer closed this as completed May 3, 2017
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

2 participants