wardbell / bardjs

Spec helpers for testing angular v.1.x apps with Mocha, Jasmine and QUnit
MIT License
178 stars 34 forks source link

Bower dependency issues with Angular 1.4 #8

Closed nareshbhatia closed 9 years ago

nareshbhatia commented 9 years ago

After upgrading to Angular 1.4, I am getting the following dependency issues with bardjs:

Unable to find a suitable version for angular, please choose one:
1) angular#~1.3.8 which resolved to 1.3.16 and is required by bardjs#0.1.3
2) angular#1.3.16 which resolved to 1.3.16 and is required by angular-mocks#1.3.16
3) angular#>=1.3.0 which resolved to 1.4.0 and is required by angular-bootstrap#0.13.0, angular-toastr#1.4.1
4) angular#~1.4.0 which resolved to 1.4.0 and is required by manage-my-money-client
5) angular#>= 1.0.8 which resolved to 1.4.0 and is required by angular-ui-router#0.2.15
6) angular#1.4.0 which resolved to 1.4.0 and is required by angular-animate#1.4.0

Could you please update bower.json to make the dependencies a little less stringent, e.g. >=1.3.8?

Also should the sinon dependency be updated to the latest release?

wardbell commented 9 years ago

Good point about ng version dependency; will do.

Do I need to update sinon dependency or simply relax its version too in the same manner as Ng? What are the issues/tradeoffs from your point of view?

nareshbhatia commented 9 years ago

I don't know how to relax the sinon dependency in bower.json - since it is picking up an explicit version (http://sinonjs.org/releases/sinon-1.12.1.js). I think at least update to latest version (1.15.3). It's working fine for me.

As a side note, I am wondering is there a reason why we are going the bower route for bardjs and sinon (I basically used gulp-patterns as my template). Since these are all test libraries, should we be using npm packages for everything? The gulp-patterns package.json file already pulls in sinon. So perhaps pull in bardjs also from there as well? I am pretty sure that karma uses the version of sinon from npm (see http://karma-runner.github.io/0.10/config/configuration-file.html)

wardbell commented 9 years ago

Sorry, I should have looked at what I was doing before I leaped. I just pushed 0.1.4 with the changes you recommended. The closest I could get to sinon v.1.15.3 was the following:

sinon": "http://sinonjs.org/releases/sinon-1.15.0.js"

because there is no "...1.15.3.js" as I write this.

The reason I support the bower route is that many folks (me included) like to run tests in the browser, not just with karma. Maybe that's not a good enough reason. I'm kind of confused about package practice and etiquette.

Please give the latest a try and let me know if I can close this issue or if I have more work to do.

Thanks for using bard!

nareshbhatia commented 9 years ago

I did run into a conflict because my bower.json was loading sinon 1.15.3. However the good news is that sinon is now available as a bower package. So you should be able to take out the hard coded dependency and simply include the latest as a bower package. See below:

$ bower install sinon --save
bower sinon#*                   cached git://github.com/cjohansen/Sinon.JS.git#1.15.3
bower sinon#*                 validate 1.15.3 against git://github.com/cjohansen/Sinon.JS.git#*
bower sinon#~1.15.3            install sinon#1.15.3
wardbell commented 9 years ago

That does not work ... at least not for me. That fails to deliver a single sinon JavaScript file. Instead, it delivers sinon in pieces that are knitted together with node by sinon.js and its many require statements. This does not work in a browser environment.

See the discussion here and on github where the author says "you will have to use a pre-built version. You can either build it yourself or get a numbered version from http://sinonjs.org." (yes, the comment about AMD applies equally to running in the browser).

The latest single-file release of sinon.js is v.1.15.0 (see big blue button at top of http://sinonjs.org)

I think you'll be fine with Karma and installing bardjs with npm install bardjs. Sure it loads sinon into the _bowercomponents directory, but you will never need it or use it if you're running tests with karma. Like many node packages, the bardjs npm install loads a ton of other crap that you don't need but then "no-biggie" because you're never deploying this anyway.

The inner _bardjs/nodemodules directory holds the latest release of sinon, in case you don't want to depend upon it yourself.

Please prove me wrong ... or adjust your bower.json accordingly.

nareshbhatia commented 9 years ago

Hmmm, I see. So the way I resolved the issue is by removing the sinon dependency from my bower.json and simply let bardjs' dependency download it.

Funny thing is that even if I remove sinon from my bower_components folder, the tests still pass. I know that they are using the browser (chrome specifically). So either they are picking up sinon from node_modules or I am wrong about the tests running from the browser and using sinon! Any ideas?