16 best JavaScript Mock libraries in 2024

share link

by marketing.admin@openweaver.com dot icon Updated: Mar 12, 2023

technology logo
technology logo

Guide Kit Guide Kit  

A mock object of a given class or interface is designed to simulate the behavior of the real object. Used to test the behavior of other objects that are dependent on this mock object. A mock object returns dummy data corresponding to some dummy input passed to it. Mock objects can be used as a replacement for real objects in unit testing, they often also record how they were used so that you can make assertions about this after the test has finished. In this kit, we will discuss the top 8 JavaScript Mock Open Source libraries that you can use in your testing project. nock - HTTP server mocking and expectations library for Node.js; sinon - Test spies, stubs and mocks for JavaScript; easy-mock - persistent service that generates mock data quickly.

nockby nock

JavaScript doticonstar image 12174 doticonVersion:v13.3.1doticon
License: Permissive (MIT)

HTTP server mocking and expectations library for Node.js

Support
    Quality
      Security
        License
          Reuse

            nockby nock

            JavaScript doticon star image 12174 doticonVersion:v13.3.1doticon License: Permissive (MIT)

            HTTP server mocking and expectations library for Node.js
            Support
              Quality
                Security
                  License
                    Reuse

                      sinonby sinonjs

                      JavaScript doticonstar image 9309 doticonVersion:v4.2.2doticon
                      License: Others (Non-SPDX)

                      Test spies, stubs and mocks for JavaScript.

                      Support
                        Quality
                          Security
                            License
                              Reuse

                                sinonby sinonjs

                                JavaScript doticon star image 9309 doticonVersion:v4.2.2doticon License: Others (Non-SPDX)

                                Test spies, stubs and mocks for JavaScript.
                                Support
                                  Quality
                                    Security
                                      License
                                        Reuse

                                          easy-mockby easy-mock

                                          JavaScript doticonstar image 8898 doticonVersion:v1.6.0doticon
                                          License: Strong Copyleft (GPL-3.0)

                                          A persistent service that generates mock data quickly and provids visualization view.

                                          Support
                                            Quality
                                              Security
                                                License
                                                  Reuse

                                                    easy-mockby easy-mock

                                                    JavaScript doticon star image 8898 doticonVersion:v1.6.0doticon License: Strong Copyleft (GPL-3.0)

                                                    A persistent service that generates mock data quickly and provids visualization view.
                                                    Support
                                                      Quality
                                                        Security
                                                          License
                                                            Reuse
                                                              JavaScript doticonstar image 3189 doticonVersion:v1.21.4doticon
                                                              License: Permissive (MIT)

                                                              Axios adapter that allows to easily mock requests

                                                              Support
                                                                Quality
                                                                  Security
                                                                    License
                                                                      Reuse

                                                                        axios-mock-adapterby ctimmerm

                                                                        JavaScript doticon star image 3189 doticonVersion:v1.21.4doticon License: Permissive (MIT)

                                                                        Axios adapter that allows to easily mock requests
                                                                        Support
                                                                          Quality
                                                                            Security
                                                                              License
                                                                                Reuse
                                                                                  JavaScript doticonstar image 2478 doticonVersion:v1.5.3doticon
                                                                                  License: Permissive (MIT)

                                                                                  A mock store for testing Redux async action creators and middleware.

                                                                                  Support
                                                                                    Quality
                                                                                      Security
                                                                                        License
                                                                                          Reuse

                                                                                            redux-mock-storeby reduxjs

                                                                                            JavaScript doticon star image 2478 doticonVersion:v1.5.3doticon License: Permissive (MIT)

                                                                                            A mock store for testing Redux async action creators and middleware.
                                                                                            Support
                                                                                              Quality
                                                                                                Security
                                                                                                  License
                                                                                                    Reuse

                                                                                                      fetch-mockby wheresrhys

                                                                                                      JavaScript doticonstar image 1202 doticonVersion:v9.11.0doticon
                                                                                                      License: Permissive (MIT)

                                                                                                      Mock http requests made using fetch

                                                                                                      Support
                                                                                                        Quality
                                                                                                          Security
                                                                                                            License
                                                                                                              Reuse

                                                                                                                fetch-mockby wheresrhys

                                                                                                                JavaScript doticon star image 1202 doticonVersion:v9.11.0doticon License: Permissive (MIT)

                                                                                                                Mock http requests made using fetch
                                                                                                                Support
                                                                                                                  Quality
                                                                                                                    Security
                                                                                                                      License
                                                                                                                        Reuse

                                                                                                                          mock-fsby tschaub

                                                                                                                          JavaScript doticonstar image 865 doticonVersion:v5.2.0doticon
                                                                                                                          License: Others (Non-SPDX)

                                                                                                                          Configurable mock for the fs module

                                                                                                                          Support
                                                                                                                            Quality
                                                                                                                              Security
                                                                                                                                License
                                                                                                                                  Reuse

                                                                                                                                    mock-fsby tschaub

                                                                                                                                    JavaScript doticon star image 865 doticonVersion:v5.2.0doticon License: Others (Non-SPDX)

                                                                                                                                    Configurable mock for the fs module
                                                                                                                                    Support
                                                                                                                                      Quality
                                                                                                                                        Security
                                                                                                                                          License
                                                                                                                                            Reuse

                                                                                                                                              jest-fetch-mockby jefflau

                                                                                                                                              JavaScript doticonstar image 837 doticonVersion:3.0.0doticon
                                                                                                                                              License: Permissive (MIT)

                                                                                                                                              There is a mock for fetch

                                                                                                                                              Support
                                                                                                                                                Quality
                                                                                                                                                  Security
                                                                                                                                                    License
                                                                                                                                                      Reuse

                                                                                                                                                        jest-fetch-mockby jefflau

                                                                                                                                                        JavaScript doticon star image 837 doticonVersion:3.0.0doticon License: Permissive (MIT)

                                                                                                                                                        There is a mock for fetch
                                                                                                                                                        Support
                                                                                                                                                          Quality
                                                                                                                                                            Security
                                                                                                                                                              License
                                                                                                                                                                Reuse

                                                                                                                                                                  mock-socketby thoov

                                                                                                                                                                  JavaScript doticonstar image 741 doticonVersion:9.0.0doticon
                                                                                                                                                                  License: Permissive (MIT)

                                                                                                                                                                  Javascript mocking library for WebSockets and Socket.IO

                                                                                                                                                                  Support
                                                                                                                                                                    Quality
                                                                                                                                                                      Security
                                                                                                                                                                        License
                                                                                                                                                                          Reuse

                                                                                                                                                                            mock-socketby thoov

                                                                                                                                                                            JavaScript doticon star image 741 doticonVersion:9.0.0doticon License: Permissive (MIT)

                                                                                                                                                                            Javascript mocking library for WebSockets and Socket.IO
                                                                                                                                                                            Support
                                                                                                                                                                              Quality
                                                                                                                                                                                Security
                                                                                                                                                                                  License
                                                                                                                                                                                    Reuse

                                                                                                                                                                                      node-mocks-httpby howardabrams

                                                                                                                                                                                      JavaScript doticonstar image 609 doticonVersion:v1.10.0doticon
                                                                                                                                                                                      License: Others (Non-SPDX)

                                                                                                                                                                                      Mock 'http' objects for testing Express routing functions

                                                                                                                                                                                      Support
                                                                                                                                                                                        Quality
                                                                                                                                                                                          Security
                                                                                                                                                                                            License
                                                                                                                                                                                              Reuse

                                                                                                                                                                                                node-mocks-httpby howardabrams

                                                                                                                                                                                                JavaScript doticon star image 609 doticonVersion:v1.10.0doticon License: Others (Non-SPDX)

                                                                                                                                                                                                Mock 'http' objects for testing Express routing functions
                                                                                                                                                                                                Support
                                                                                                                                                                                                  Quality
                                                                                                                                                                                                    Security
                                                                                                                                                                                                      License
                                                                                                                                                                                                        Reuse

                                                                                                                                                                                                          react-mockby skidding

                                                                                                                                                                                                          JavaScript doticonstar image 369 doticonVersion:Currentdoticon
                                                                                                                                                                                                          License: Permissive (MIT)

                                                                                                                                                                                                          Declarative mocks for React state and global APIs

                                                                                                                                                                                                          Support
                                                                                                                                                                                                            Quality
                                                                                                                                                                                                              Security
                                                                                                                                                                                                                License
                                                                                                                                                                                                                  Reuse

                                                                                                                                                                                                                    react-mockby skidding

                                                                                                                                                                                                                    JavaScript doticon star image 369 doticonVersion:Currentdoticon License: Permissive (MIT)

                                                                                                                                                                                                                    Declarative mocks for React state and global APIs
                                                                                                                                                                                                                    Support
                                                                                                                                                                                                                      Quality
                                                                                                                                                                                                                        Security
                                                                                                                                                                                                                          License
                                                                                                                                                                                                                            Reuse
                                                                                                                                                                                                                              JavaScript doticonstar image 289 doticonVersion:v2.3.0doticon
                                                                                                                                                                                                                              License: Permissive (BSD-3-Clause)

                                                                                                                                                                                                                              A module to mock window.localStorage and window.sessionStorage in Jest

                                                                                                                                                                                                                              Support
                                                                                                                                                                                                                                Quality
                                                                                                                                                                                                                                  Security
                                                                                                                                                                                                                                    License
                                                                                                                                                                                                                                      Reuse

                                                                                                                                                                                                                                        jest-localstorage-mockby clarkbw

                                                                                                                                                                                                                                        JavaScript doticon star image 289 doticonVersion:v2.3.0doticon License: Permissive (BSD-3-Clause)

                                                                                                                                                                                                                                        A module to mock window.localStorage and window.sessionStorage in Jest
                                                                                                                                                                                                                                        Support
                                                                                                                                                                                                                                          Quality
                                                                                                                                                                                                                                            Security
                                                                                                                                                                                                                                              License
                                                                                                                                                                                                                                                Reuse
                                                                                                                                                                                                                                                  JavaScript doticonstar image 271 doticonVersion:0.0.8doticon
                                                                                                                                                                                                                                                  License: Permissive (MIT)

                                                                                                                                                                                                                                                  ✅Simple and straightforward Vuex Store mock for vue-test-utils

                                                                                                                                                                                                                                                  Support
                                                                                                                                                                                                                                                    Quality
                                                                                                                                                                                                                                                      Security
                                                                                                                                                                                                                                                        License
                                                                                                                                                                                                                                                          Reuse

                                                                                                                                                                                                                                                            vuex-mock-storeby posva

                                                                                                                                                                                                                                                            JavaScript doticon star image 271 doticonVersion:0.0.8doticon License: Permissive (MIT)

                                                                                                                                                                                                                                                            ✅Simple and straightforward Vuex Store mock for vue-test-utils
                                                                                                                                                                                                                                                            Support
                                                                                                                                                                                                                                                              Quality
                                                                                                                                                                                                                                                                Security
                                                                                                                                                                                                                                                                  License
                                                                                                                                                                                                                                                                    Reuse

                                                                                                                                                                                                                                                                      ioredis-mockby stipsan

                                                                                                                                                                                                                                                                      JavaScript doticonstar image 289 doticonVersion:v8.6.0doticon
                                                                                                                                                                                                                                                                      License: Permissive (MIT)

                                                                                                                                                                                                                                                                      Emulates ioredis by performing all operations in-memory.

                                                                                                                                                                                                                                                                      Support
                                                                                                                                                                                                                                                                        Quality
                                                                                                                                                                                                                                                                          Security
                                                                                                                                                                                                                                                                            License
                                                                                                                                                                                                                                                                              Reuse

                                                                                                                                                                                                                                                                                ioredis-mockby stipsan

                                                                                                                                                                                                                                                                                JavaScript doticon star image 289 doticonVersion:v8.6.0doticon License: Permissive (MIT)

                                                                                                                                                                                                                                                                                Emulates ioredis by performing all operations in-memory.
                                                                                                                                                                                                                                                                                Support
                                                                                                                                                                                                                                                                                  Quality
                                                                                                                                                                                                                                                                                    Security
                                                                                                                                                                                                                                                                                      License
                                                                                                                                                                                                                                                                                        Reuse

                                                                                                                                                                                                                                                                                          node-mock-serverby smollweide

                                                                                                                                                                                                                                                                                          JavaScript doticonstar image 236 doticonVersion:0.25.4doticon
                                                                                                                                                                                                                                                                                          License: Permissive (MIT)

                                                                                                                                                                                                                                                                                          File based Node REST API mock server

                                                                                                                                                                                                                                                                                          Support
                                                                                                                                                                                                                                                                                            Quality
                                                                                                                                                                                                                                                                                              Security
                                                                                                                                                                                                                                                                                                License
                                                                                                                                                                                                                                                                                                  Reuse

                                                                                                                                                                                                                                                                                                    node-mock-serverby smollweide

                                                                                                                                                                                                                                                                                                    JavaScript doticon star image 236 doticonVersion:0.25.4doticon License: Permissive (MIT)

                                                                                                                                                                                                                                                                                                    File based Node REST API mock server
                                                                                                                                                                                                                                                                                                    Support
                                                                                                                                                                                                                                                                                                      Quality
                                                                                                                                                                                                                                                                                                        Security
                                                                                                                                                                                                                                                                                                          License
                                                                                                                                                                                                                                                                                                            Reuse

                                                                                                                                                                                                                                                                                                              mock-knexby jbrumwell

                                                                                                                                                                                                                                                                                                              JavaScript doticonstar image 230 doticonVersion:v0.4.12doticon
                                                                                                                                                                                                                                                                                                              License: Permissive (MIT)

                                                                                                                                                                                                                                                                                                              A mock knex adapter for simulating a database during testing

                                                                                                                                                                                                                                                                                                              Support
                                                                                                                                                                                                                                                                                                                Quality
                                                                                                                                                                                                                                                                                                                  Security
                                                                                                                                                                                                                                                                                                                    License
                                                                                                                                                                                                                                                                                                                      Reuse

                                                                                                                                                                                                                                                                                                                        mock-knexby jbrumwell

                                                                                                                                                                                                                                                                                                                        JavaScript doticon star image 230 doticonVersion:v0.4.12doticon License: Permissive (MIT)

                                                                                                                                                                                                                                                                                                                        A mock knex adapter for simulating a database during testing
                                                                                                                                                                                                                                                                                                                        Support
                                                                                                                                                                                                                                                                                                                          Quality
                                                                                                                                                                                                                                                                                                                            Security
                                                                                                                                                                                                                                                                                                                              License
                                                                                                                                                                                                                                                                                                                                Reuse

                                                                                                                                                                                                                                                                                                                                  See similar Kits and Libraries