UNPKG

@northscaler/redis-test-support

Version:

Redis Node.js Development Test Support Library

101 lines (62 loc) 3.57 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Home</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Home</h1> <h3> </h3> <section> <article><h1><code>redis-test-support</code></h1> <p>Handy-dandy Redis integration testing utility that starts a local Docker container running Redis if you're not running in a CI/CD pipeline. This allows you to run integration tests locally in a manner similar to how they'd be run in the CI/CD pipeline. This module does nothing when running in a CI build pipeline, because Redis should be configured as part of the build via something like <a href="https://docs.gitlab.com/ee/ci/yaml/#services"><code>.gitlab-ci.yml</code>'s <code>services</code></a> element.</p> <p>This package is intended to be installed in your project in <code>devDependencies</code>.</p> <p>Your application must install its desired version of <a href="https://www.npmjs.com/package/redis"><code>redis</code></a>.</p> <blockquote> <p>NOTE: requires a Unix-y shell (<code>/usr/bin/env sh</code>) to be available. This is not designed to run on Windows; PRs/MRs welcome.</p> </blockquote> <p>See [src/test/integration/redis/redis.spec.js] for usage, but it's basically</p> <pre class="prettyprint source lang-javascript"><code>const redisConnect = require('redis-test-support') const redisClient = await redisConnect() // now you can use redis client </code></pre> <h2>Configuration</h2> <p>The default configuration is pretty conventional, with the sole exception of the default port that Redis will listen on for clients. Instead of <code>6379</code>, which might already be in use on developers' machines when they run integration tests, the default configuration uses <code>46379</code>. It is a <code>TODO</code> to search for an available port.</p> <blockquote> <p>NOTE: This module detects when it's running in a CI/CD pipeline by seeing if the environment variable <code>CI</code> is of nonzero length.</p> </blockquote> <h3>Environment variables</h3> <p>The following environment variables can be set to configure it:</p> <ul> <li>REDIS_TEST_SUPPORT_TAG: The tag of the <a href="https://hub.docker.com/_/redis"><code>redis</code> Docker image</a> or custom image to use, default &quot;latest&quot;</li> <li>REDIS_TEST_SUPPORT_PORT: visible client port on <code>localhost</code> to map to container port, default is content of <code>redis/default-redis-test-port</code></li> <li>REDIS_TEST_SUPPORT_CONTAINER: name of container, default is content of file <code>redis/default-redis-test-container</code></li> <li>REDIS_TEST_SUPPORT_CONTAINER_PORT: redis client port in container, default <code>9042</code></li> <li>REDIS_TEST_SUPPORT_IMAGE: docker image name, default <code>redis</code></li> </ul></article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Nov 12 2020 16:26:48 GMT+0000 (UTC) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>