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

JsMockito with NodeJS #7

Open
luciferous opened this issue Sep 19, 2011 · 2 comments
Open

JsMockito with NodeJS #7

luciferous opened this issue Sep 19, 2011 · 2 comments

Comments

@luciferous
Copy link

Hi Chris, great work with JsMockito. I'm using it in a browser and NodeJS environment. It's unclear to me if there is a roadmap for getting JsMockito to work with NodeJS, but I thought I'd contribute my half-solution so other people looking to do the same may build on top of it.

The details are in https://gist.github.com/1227705.

@cleishm
Copy link
Owner

cleishm commented Sep 19, 2011

There is no particular roadmap. It's pretty usable as is, but enhancement's
are always good.

I'm not sure exactly what this patch you've sent does: the diff isn't overly
explanatory. If you'd like to contribute a change, please fork the
repository on github, add your changes (making sure you write appropriate
test cases) and then send a pull request with the detail.

cheers,
chris

On 20 September 2011 00:00, Neuman Vong <
[email protected]>wrote:

Hi Chris, great work with JsMockito. I'm using it in a browser and NodeJS
environment. It's unclear to me if there is a roadmap for getting JsMockito
to work with NodeJS, but I thought I'd contribute my half-solution so other
people looking to do the same may build on top of it.

The details are in https://gist.github.com/1227705.

Reply to this email directly or view it on GitHub:
#7

@jefflage
Copy link

jefflage commented Feb 3, 2012

chris,

i just spent some time getting jsmockito plugged into nodejs, specifically into a vows test, and i now understand what luciferous did, at least with the exports.

Both JSMockito and JSHamcrest have support for copying public functions into a target context, but the issue is that they don't export anything by default. In Node, you use require() to get access to another module. The object returned by require is effective the public API for the module you required. That object can get it's members in a number of different ways, but the basic issue is that it has to have something. Given that JSMockito don't export anything by default, you can't get a handle to anything that would allow you to run the import JSMockito.Integration.importTo() function.

So to work with Node JSMockito has to export something, thus the addition of the line: JsMockito.Integration.importTo( exports );

Does this help?
-Jeff

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

3 participants