Since Linux and macOS handle sockets differently, please run tests in a Docker container to have a consistent Linux environment for running tests.
-
Run all tests
npm run test:docker
-
Run a specific test file
npm run test:docker test/server.js
-
Run all
direct ipv6test cases across all testsnpm run test:docker test/server.js -- --grep "direct ipv6"
Note: for test in Docker no changes in /etc/hosts needed.
-
Node.js 18+ (see
.nvmrcfor exact version) -
For MacOS with ARM CPUs install Rosetta (workaround for puppeteer)
-
Update
/etc/hosts# Used by proxy-chain NPM package tests 127.0.0.1 localhost 127.0.0.1 localhost-testThe
localhostentry is for avoiding dual-stack issues, e.g. when the test server listens at ::1 (results of getaddrinfo have specified order) and the client attempts to connect to 127.0.0.1 .The
localhost-testentry is a workaround to PhantomJS' behavior where it skips proxy servers for localhost addresses.
-
Run all tests
npm run test -
Run a specific test file
npm run test test/anonymize_proxy.js