There are several options how to run Dredd on your machine or in your Continuous Integration.
Instead, you should have separate containers for each process and run them together with Dredd using Docker Compose. You can use --abort-on-container-exit and --exit-code-from with Docker Compose to manage the tear down of all the other containers when the Dredd tests finish.
Installing Node.js and npm¶
If your internet connection is restricted (VPN, firewall, proxy), you need to configure npm:
npm config set proxy "http://proxy.example.com:8080" npm config set https-proxy "https://proxy.example.com:8080"
Otherwise you’ll get similar errors during Dredd installation:
npmERR! Cannot read property 'path' of null npmERR!code ECONNRESET npmERR!network socket hang up
Later be sure to read how to set up Dredd to correctly work with proxies.
Now that you have everything prepared, you can finally run npm to install Dredd:
npm install dredd --global
If you get
EACCES permissions errors, try one of the officially recommended solutions. In the worst case, you can run the command again with
You can verify Dredd is correctly installed by printing its version number:
Now you can start using Dredd!
Adding Dredd as a dev dependency¶
If your API project is also an npm package, you may want to add Dredd as a dev dependency instead of installing it globally.
Make sure your project is an npm package with a
In the root of the project run
npm install dredd --save-dev
Once the installation is complete, you can run Dredd from the root of the project as
This is how Dredd is installed in the dredd-example repository, so you may want to see it for inspiration.