Repository files navigation

RedMock

Mock Redis server for Node unit tests.

Requires Node version 5.7.0 or higher for the newest language features.

Purpose

I created this project to help unit test an application that I was writing that used Redis for caching. I didn't want to stub out my client library code since I felt that would not be reliable enough, and I didn't want to get to functional/integration tests and find that my code was broken. I wanted to support sentinel and clustering, and couldn't find something that I felt would work, so I wrote this POS.

Usage

Starting the server

Call the start method after creating a new instance of the RedisServer class. This method returns an ES6 promise.

constRedisServer=require('redmock');letredisServer=newRedisServer();redisServer.start().then((res)=>{// Server is now up}).catch((err)=>{// Deal with error});

Stopping the server

Call the stop method. This method returns an ES6 promise. You do not have to worry about catching errors from this method.

redisServer.stop().then((res)=>{// Server is now stopped});

Example test

// require/import needed crapdescribe('SomeTestSpec',()=>{letredisServer,underTest;// Start the serverbefore((done)=>{redisServer=newRedisServer();redisServer.start().then((res)=>{done();}).catch((err)=>{done(err);});});// Stop the serverafter((done)=>{redisServer.stop().then((res)=>{done();});});describe('#somemethod()',()=>{beforeEach(()=>{underTest=newUnderTest();});it('should test it',()=>{returnunderTest.somemethod().should.eventually.equal(true);});});});

About

Mock redis server for node.js unit tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

RedMock

Mock Redis server for Node unit tests.

Requires Node version 5.7.0 or higher for the newest language features.

Purpose

I created this project to help unit test an application that I was writing that used Redis for caching. I didn't want to stub out my client library code since I felt that would not be reliable enough, and I didn't want to get to functional/integration tests and find that my code was broken. I wanted to support sentinel and clustering, and couldn't find something that I felt would work, so I wrote this POS.

Usage

Starting the server

Call the start method after creating a new instance of the RedisServer class. This method returns an ES6 promise.

constRedisServer=require('redmock');letredisServer=newRedisServer();redisServer.start().then((res)=>{// Server is now up}).catch((err)=>{// Deal with error});

Stopping the server

Call the stop method. This method returns an ES6 promise. You do not have to worry about catching errors from this method.

redisServer.stop().then((res)=>{// Server is now stopped});

Example test

// require/import needed crapdescribe('SomeTestSpec',()=>{letredisServer,underTest;// Start the serverbefore((done)=>{redisServer=newRedisServer();redisServer.start().then((res)=>{done();}).catch((err)=>{done(err);});});// Stop the serverafter((done)=>{redisServer.stop().then((res)=>{done();});});describe('#somemethod()',()=>{beforeEach(()=>{underTest=newUnderTest();});it('should test it',()=>{returnunderTest.somemethod().should.eventually.equal(true);});});});

About

Mock redis server for node.js unit tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

RedMock

Mock Redis server for Node unit tests.

Requires Node version 5.7.0 or higher for the newest language features.

Purpose

I created this project to help unit test an application that I was writing that used Redis for caching. I didn't want to stub out my client library code since I felt that would not be reliable enough, and I didn't want to get to functional/integration tests and find that my code was broken. I wanted to support sentinel and clustering, and couldn't find something that I felt would work, so I wrote this POS.

Usage

Starting the server

Call the start method after creating a new instance of the RedisServer class. This method returns an ES6 promise.

constRedisServer=require('redmock');letredisServer=newRedisServer();redisServer.start().then((res)=>{// Server is now up}).catch((err)=>{// Deal with error});

Stopping the server

Call the stop method. This method returns an ES6 promise. You do not have to worry about catching errors from this method.

redisServer.stop().then((res)=>{// Server is now stopped});

Example test

// require/import needed crapdescribe('SomeTestSpec',()=>{letredisServer,underTest;// Start the serverbefore((done)=>{redisServer=newRedisServer();redisServer.start().then((res)=>{done();}).catch((err)=>{done(err);});});// Stop the serverafter((done)=>{redisServer.stop().then((res)=>{done();});});describe('#somemethod()',()=>{beforeEach(()=>{underTest=newUnderTest();});it('should test it',()=>{returnunderTest.somemethod().should.eventually.equal(true);});});});

About

Mock redis server for node.js unit tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages