-
Notifications
You must be signed in to change notification settings - Fork 69
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
chai and jquery as peerDependencies #40
Comments
Definitely chai makes sense as a peer dependency. Not sure jQuery does though -- it should work with pretty much any jQuery version, so there's not really anything for peer dependencies to enforce. |
https://github.com/chaijs/chai-jquery/blob/master/chai-jquery.js#L8 If you need jquery to run, then jquery is a dependency. If you are using jquery as a collaborator, then is a peerDependency In the node scenario, with your actual code: var chai = require('chai'),
jquery = require('jquery'),
utils = {.....}
chaiJquery = require('chai-jquery')(chai, utils, jquery); You are delegating to the node developer to install both jquery and chai (strong dependencies) in the app, and pass it to your factory. Therefore, in the internals chai-jquery is not using a jquery dependency: you do not have a IMHO, a better approach can be let jquery-chai to use the its peerDependencies (with chaiJquery = require('chai-jquery')(utils); in your code... module.exports = function(utils) {
return chaiJquery(require('chai'), utils, require('jquery'));
}; taking the user installed dependencies. NPM will install them if they are not present. This is exactly the same behaviour that happens in the browser: Your code assumes jquery and chai have been included in the dom, With this approach you will have a consistent API between the 3 flavors: Node, AMD, and script, because the package manager has taken the responsibility of managing deps With jquery as peer dependency, the user will use the same jquery version automatically in both their test (via chai-jquery) and its own code WDYT? |
Yeah, it's true that the node API is currently a second class citizen. The standard convention for chai plugins is to export a function which can be passed to On the other hand, some people want to be able to specify the jQuery object (#36), so they can pass On the third hand, the wrapper hard-codes a jQuery dependency for AMD already. So it's a bit of a mess and I'm not entirely sure what the best way of satisfying everybody is. |
The least bad solution is up to you ;) |
I have a situation where I also would like to specify the jQuery object -- I'm juggling between a parent and a child iframe and there is a strong possibility of 2 different jQuery objects - and |
The pull request #66 I just made fixes issues with instanceof checks. It's still backward compatible, but I would like to get rid of the magic for good. |
Have you consider using
To enable npm to manage your dependencies, and share the dependencies lifecicle with other peer projects (like karma plugins)?
The text was updated successfully, but these errors were encountered: