kevicency / karma-sinon-chai Goto Github PK
View Code? Open in Web Editor NEWThis project forked from xdissent/karma-chai
Karma + Mocha + Sinon + Chai = ❤
License: MIT License
This project forked from xdissent/karma-chai
Karma + Mocha + Sinon + Chai = ❤
License: MIT License
The latest Sinon release has files in a different location and does no longer work with karma-sinon-chai.
Changing package.json from
"dependencies": {
"chai": "^1.10",
"sinon": "^1.12",
"sinon-chai": "^2.6",
"lodash": "^2.4.1"
},
to
"dependencies": {
"chai": "^1.10",
"sinon": "1.12",
"sinon-chai": "2.6",
"lodash": "^2.4.1"
},
and then deleting node_modules dir and running 'npm install' again makes things work again.
For example, there is already a karma-chai plugin, a karma-sinon plugin which both work well. And neither of them includes their own copy of the respective package.
If this is a plugin which intends to auto load "sinon-chai", then you should just add the entry of snon-chai to the files array and that's it. This also would save you a lot of efforts of keeping track of the dependencies updates.
Thoughts?
Hi
In my organisation this package is marked as malicious and cannot be downloaded. Does anyone else have this issue?
The 'soon to be very grey haired' developer
Hey,
I really like this module, great work!
When I tried to upgrade to 3.0.0 a few tests broke. I was just wondering if there is a changelog somewhere mentioning the breaking changes?
Why are there breaking changes, is it because Sinon or Chai released new major version? If so, maybe I can find a document describing the breaking changes there?
Cheers.
Hey, not sure if it was intended but 1.3.1 was published to NPM this morning with a major dependency jump from Sinonv1 to Sinonv2. You may want to consider the dropping of Sinon1 as a major release to not break legacy rebuilds.
peerDependencies should probably be using greater than or equal to. As an example, sinon has a new major version coming out and npm complains since since its not in the same range
It changed sinon's peerDep to require a major version change. This should have made this a major version update as well instead of a minor
PhantomJS 1.9.8 (Mac OS X) ERROR
RangeError: Maximum call stack size exceeded.
at /Users/dis/JEDI/amarosa_mod/src/app/node_modules/karma-sinon-chai/node_modules/chai/chai.js:3421
When I roll back to 0.2.x everything works well.
While I did #56, I noticed that the lolex dependency is still on version 1.6.0 while lolex is now on 2.3.2. Also, looking at the index.js
in this package, it looks like it doesn't use lolex so much as provide it. I've personally never needed lolex. Wouldn't it be nice if lolex was an optional dependency? That way, people can bring whatever version of lolex they want. Just a thought.
Let me know if that's something you'd be into supporting. I'd be happy to make a PR.
I´m running into a problem with Karma 0.12 and its siblings peer dependencies requirements.
I was getting an error on line 69 in sinon-timers.js saying "Can't read property 'install' on undefined". After looking all around, the only thing that worked was this repo that added lolex as a more explicit karma dependency: https://github.com/wombatsecurity/karma-lolex-sinon-chai.
You might consider merging over their master commits.
https://github.com/kmees/karma-sinon-chai/blob/master/index.js#L10 needs to check that str.indexOf(substr) >= 0, otherwise if there is a path with length exactly one less than the relative path to sinon, then this test will incorrectly return true.
Might be better to just specify peer dependencies of *
version for these and let the consumer decide which version to install.
Is this project still being maintained? There are a few critical issues preventing users from using this package successfully, and the PR's seem to be sitting untouched. For the time being, to unblock myself, I have forked this to: https://github.com/davezuko/karma-better-sinon-chai and published it to npm (npm i karma-better-sinon-chai
). I will gladly deprecate this package if the issues mentioned below get resolved and published; just wanting to help out!
lolex
is a dependency but is marked as a peerDependency
. This means users must install karma-sinon-chai
and then, after some debugging, realize that they must install it themselves. Futhermore, peerDependencies
are deprecated in npm3. The relevant issue has been untouched since February.sinon@^1.7.2
no longer includes the sinon-timers
package, and this is explicitly referenced from karma-sinon-chai
here. A PR to fix this has remained unmerged for over a month.When I run karma I got this warning every time:
06 05 2016 13:14:36.016:WARN [watcher]: Pattern "...node_modules\sinon\pkg\sinon-timers.js" does not match any file.
I think, the problem is this line: https://github.com/kmees/karma-sinon-chai/blob/master/index.js#L31.
Because in [email protected] this file is not exist.
The pull request #40 is not available in the npm repository.
Did you plan to release 1.2.4 soon?
Looks like it's the same issue with #15, which has been closed.
Still having the same issue with v1.1.0
Error message is:
PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR
Error: Mismatched anonymous define() module: function () {
return sinonChai;
}
http://requirejs.org/docs/errors.html#mismatch
at /Users/wwluo/work/ctp-mobile/node_modules/requirejs/require.js:140
karma config is:
frameworks: ['mocha', 'requirejs', 'sinon-chai']
rolling back to v0.2.0 fixes the issue.
I replaced karma-chai with karma-sinon-chai in my working karma/mocha/chai Grunt configuration, and now I get:
Uncaught Error: Mismatched anonymous define() module: function () {
return sinonChai;
}
My Karma configuration has
frameworks: ['mocha', 'requirejs', 'chai-datetime', 'sinon-chai']
This looks similar to an old Chai issue: princed/karma-chai-plugins#3
When running with karma and mocha there is an option to execute only specific tests with a grep expression
karma start
karma run -- --grep="manager tests"
but this doesn't work when using the karma-sinon-chai plugin since the command line config is lost in the chai-adapter.js.
Replacing the following line in chai-adapter.js
karma.start();
with
karma.start(karma.config);
makes the mocha adapter pick up the grep argument and only execute the desired tests. Not sure if this is the correct place to fix it, but greping works as expected when the sinon-chai plugin is not included in the karma frameworks config.
I have yet to completely confirm this, I'll work up some tests, but I believe the addition of setting the karma.loaded
is causing some strange issues.
In my tests I now have tons of TypeError: Cannot read property 'call' of undefined
, as well as half my stubs stopped working. I'll try to pull together some minimal examples to see if it's just the way my tests are written or if this is a breaking change for all of karma v0.13.x.
Karma v0.13.22
Sinon v1.17.4
Chai v3.5.0
Version v1.2.2 of this module works, v1.2.3 works if I comment out the karma.loaded
code.
Could you please add support for chai 4.0? Sinon-chai already supports it.
I did a quick test with https://github.com/vuejs-templates/webpack, and it worked fine.
Support was added for chai^4.0.0
in #48 but the version #
in package.json
wasn't advanced to 1.3.2
;
npm
has the correct version stamp 1.3.2
and correct package.json
but it doesn't match what is in master (https://github.com/kmees/karma-sinon-chai/blob/master/package.json)
npm WARN peerDependencies The peer dependency lolex@^1.4.0 included from karma-sinon-chai will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency sinon-chai@^2.8.0 included from karma-sinon-chai will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
Hi, sorry if this is a bit OCD but... I'm trying to tidy up my npm dependencies in a project using "npm outdated" and getting the below message; is it possible you could update the lodash version dependency in karma-sinon-chai ? Just thought I'd ask. Thank you, -dB
davids-mbp:dBWeb davidwbarrows$ npm outdated
Package Current Wanted Latest Location
cli-color 0.3.3 0.3.3 1.0.0 cli-color
lodash 2.4.2 2.4.2 3.10.1 lodash
merge-stream 0.1.8 0.1.8 1.0.0 merge-stream
davids-mbp:dBWeb davidwbarrows$ npm update
npm WARN unmet dependency /Users/davidwbarrows/Data/Computing/Angular/dBWeb/node_modules/karma-sinon-chai requires lodash@'^2.4.1' but will load
npm WARN unmet dependency /Users/davidwbarrows/Data/Computing/Angular/dBWeb/node_modules/lodash,
npm WARN unmet dependency which is version 3.10.1
[email protected] node_modules/lodash
While working on a project that is using RequireJs, I found that to get Karma runner to work with karma-sinon-chai. The setting in karma.conf.js needs to read frameworks: ['mocha', 'requirejs', 'sinon-chai']. It appears to be a problem not being able to set the properties below if 'requirejs' is not set before 'sinon-chai':
Is that the correct setting for using karma-sinon-chai with RequireJs
location:
https://github.com/kmees/karma-sinon-chai/blob/c0663bcf150a4f28b0225f91d878a33d2ce8992d/index.js#L13-L22
reprocude:
_isDuplicate([{ pattern: '/Users/node/node_modules/chai/chai.js' }], '/Users/node/node_modules/chai/chai.js');
expect: true
actual: false
I don't see why this shouldn't support it out of the box. It should only require a change to the version of the peerDependencies to include the new major version of sinon-chai.
I just had trouble installing the latest version of karma-sinon-chai, and it looks like you cannot always rely on bower being present in the local node_modules folder.
My project also has bower as a dependency, and as such the post_install 2dc5275 failed as bower was present at the top level node_modules folder.
See isaacs/npm#1341 for more details of the underlying npm behaviour.
Hi,
After adding this package to my project karma throws and refuses to start:
ERROR [karma-server]: Server start failed on port 9876: Error: Cannot find module 'sinon/package.json'
Is there any more dep. I need to install along this package or what could be wrong?
Thanks!
I'm using:
"karma": "^4.0.0",
chrome: 71
OSX.
Could be bump the peer dependency to "sinon@>=2.1.0 <6" ?
What does it mean?
17 07 2015 16:45:31.239:INFO [karma]: Karma v0.13.1 server started at http://localhost:9876/
17 07 2015 16:45:31.249:INFO [launcher]: Starting browser PhantomJS
17 07 2015 16:45:31.481:INFO [PhantomJS 1.9.8 (Linux 0.0.0)]: Connected on socket 3EAMNnOhXQnVs70-AAAA with id 12171161
PhantomJS 1.9.8 (Linux 0.0.0) ERROR
ReferenceError: Can't find variable: chai
at /home/kuchumovn/pussy_face/node_modules/karma-sinon-chai/node_modules/sinon-chai/lib/sinon-chai.js:9
[16:45:31] 'test' errored after 14 s
[16:45:31] Error: 1
at formatError (/usr/local/lib/node_modules/gulp/bin/gulp.js:169:10)
at Gulp.<anonymous> (/usr/local/lib/node_modules/gulp/bin/gulp.js:195:15)
at Gulp.EventEmitter.emit (events.js:95:17)
at Gulp.Orchestrator._emitTaskDone (/home/kuchumovn/pussy_face/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
at /home/kuchumovn/pussy_face/node_modules/gulp/node_modules/orchestrator/index.js:275:23
at finish (/home/kuchumovn/pussy_face/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
at cb (/home/kuchumovn/pussy_face/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
at removeAllListeners (/home/kuchumovn/pussy_face/node_modules/karma/lib/server.js:301:7)
at Server.<anonymous> (/home/kuchumovn/pussy_face/node_modules/karma/lib/server.js:312:9)
at Server.g (events.js:180:16)
at Server.EventEmitter.emit (events.js:117:20)
at net.js:1273:10
at process._tickCallback (node.js:415:13)
They say:
Your unit test has the line require('../index'), but the problem is that your test is going to run in a browser environment, which does not have a native require function (hence the ReferenceError). If you need to include a separate file you could us the "requirejs" library (which is intended for browsers). Or you could use a <script> tag in your HTML file? Or maybe just a simple Ajax call...
npm WARN [email protected] requires a peer of sinon@^2.1.0 but none was installed.
Is there any plan to update that peer dependency?
Hello,
Since I moved my project from 1.1.0 to 1.2.0, I got the following error:
Error: Cannot find module 'lolex'
at Function.Module._resolveFilename (module.js:339:15)
at Function.require.resolve (internal/module.js:23:19)
at framework (/…/node_modules/karma-sinon-chai/index.js:26:40)
After upgrading karma
to 1.1.0, we got the error (Travis Build)
You need to include some adapter that implements __karma__.start method!
I found the problem being this plugin. After removing from the karma config, the tests ran again. To make sinon work without this plugin, I used the configuration mentioned here:
npm WARN [email protected] requires a peer of sinon@^2.1.0 but none is installed. You must install peer dependencies yourself.
I have
"sinon": "^4.0.1",
"chai": "^4.1.2",
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.