Registry / testing / git-http-mock-server

git-http-mock-server

JSON →
library2.0.0jsnpmunverified

A lightweight HTTP/SSH mock server for testing Git clone and push operations against test fixture repositories. Version 2.0.0 (June 2020) adds full Git Protocol Version 2 support. Designed specifically for test suites, it uses copy-on-write to prevent persistent changes to repos and supports parallel test execution. Unlike git-http-server, it includes built-in CORS headers for browser tests with isomorphic-git, HTTP Basic Auth for 401 testing, and Git hooks. The SSH variant (git-ssh-mock-server) supports anonymous, password, and public key authentication. Released under MIT license with moderate maintenance activity.

npm install git-http-mock-server
INSTALL
IMPORT
SIG · GIT-HTTP-MOCK-SERV
G
git-http-mock-server
testingjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Installs and runs the mock server via CLI, demonstrating clone/push operations and daemon mode with environment variables.

// No programmatic API; CLI usage shown below // Step 1: Install as dev dependency // npm install --save-dev git-http-mock-server // Step 2: cd to a directory with bare git repos // For example: __fixtures__ containing test-repo1.git // Step 3: Start the HTTP server // $ git-http-mock-server // Step 4: In another shell, clone and push // $ git clone http://localhost:8174/test-repo1.git // $ git push http://localhost:8174/test-repo1.git main // For SSH version: // $ git-ssh-mock-server // $ git clone ssh://localhost:2222/test-repo1.git // To run as daemon: // $ git-http-mock-server start // $ # do tests // $ git-http-mock-server stop // Environment variables: // GIT_HTTP_MOCK_SERVER_PORT (default 8174) // GIT_SSH_MOCK_SERVER_PORT (default 2222) // GIT_HTTP_MOCK_SERVER_ROOT (default cwd) // GIT_HTTP_MOCK_SERVER_ALLOW_ORIGIN (default *) // GIT_SSH_MOCK_SERVER_PASSWORD (set for password auth)
git-http-mock-server --version
Debug
Known issues
breakingVersion 2.0.0 drops support for git-http-backend npm module, requiring native git installation.
fix
Ensure git is installed on the machine and available in PATH.
affects: >=2.0.0
gotchaSSH server requires the ssh2 npm module, which may have native compilation issues on some platforms.
fix
Install build tools if using npm install; consider using pre-built binaries.
affects: >=1.0.0
gotchaThe server writes PID file to current working directory; running 'start' and 'stop' from different directories will not stop the server.
fix
Always run start/stop from the same working directory.
affects: >=1.0.0
Errors
Common errors & fixes
Error: spawn git-http-backend ENOENT
git is not installed or not in PATH.
fix
Install git and ensure it's available in your system PATH.
Error: listen EADDRINUSE :::8174
Port 8174 is already in use by another process.
fix
Set GIT_HTTP_MOCK_SERVER_PORT to a different port, e.g., export GIT_HTTP_MOCK_SERVER_PORT=9000
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
gitoptionalRequires native git installed for git-http-backend process.
Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
git-http-mock-server — npm install git-http-mock-server · libregistry