I'm using Jasmine for testing client & server side javascript and need to do some mocking. Has anyone got any suggestions for a good javascript mocking framework?
Mock Objects are a Code Smell But mock objects are more often smelly because they are telling you something about the system under test. A Code Smell is defined as “a hint that something has gone wrong somewhere in your code”.
Jest was the most popular JavaScript unit testing framework in 2020. For web apps that are based on React, Jest is the preferred framework. Apart from React, Jest supports unit testing of Angular, VueJS, NodeJS, and others.
Sinon JS is a popular JavaScript library that lets you replace complicated parts of your code that are hard to test for “placeholders,” so you can keep your unit tests fast and deterministic, as they should be.
I tried this once, but ended up refactoring instead so it wasn't needed. It doesn't have dependencies, so it should work just fine on node.js. http://sinonjs.org/
These are testing frameworks, but some of them include mocking frameworks internally: http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#JavaScript
I have not tried this one out(yet), but you could try node-gently created by Felix Geisendörfer. Right now I saw nodemock update at search.npmjs.org which is commited frequently also.
Quick search gave me:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With