Installing Bruno CLI
The Bruno CLI is distributed as an npm package (@usebruno/cli) and can be installed globally or as a project dependency.
Global Installation
Install Bruno CLI globally to use it across all your projects:
npm install -g @usebruno/cli
After installation, verify it’s working:
Project Installation
Install as a development dependency in your project:
npm install --save-dev @usebruno/cli
Then add scripts to your package.json:
{
"scripts": {
"test:api": "bru run",
"test:api:local": "bru run --env local",
"test:api:production": "bru run --env production --reporter-junit results.xml"
}
}
Run the tests:
Check the installed version:
Get help and see available commands:
System Requirements
Node.js version: Bruno CLI requires Node.js 14 or higher.
- Node.js: v14.0.0 or higher
- npm: v6.0.0 or higher (or equivalent yarn/pnpm version)
- Operating Systems: Linux, macOS, Windows
CI/CD Environment Installation
For CI/CD pipelines, install as part of your build process:
name: API Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Bruno CLI
run: npm install -g @usebruno/cli
- name: Run API Tests
run: bru run --reporter-junit results.xml
working-directory: ./api-tests
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: ./api-tests/results.xml
Docker Installation
Create a Dockerfile for running Bruno CLI tests:
FROM node:18-alpine
# Install Bruno CLI
RUN npm install -g @usebruno/cli
# Copy your collection
WORKDIR /app
COPY ./api-collection /app
# Run tests
CMD ["bru", "run", "--reporter-junit", "results.xml"]
Build and run:
docker build -t bruno-tests .
docker run --rm -v $(pwd)/results:/app/results bruno-tests
Updating Bruno CLI
Keep your CLI up to date with the latest features:
npm update -g @usebruno/cli
Troubleshooting
Command Not Found
If bru is not recognized after installation:
-
Check npm global path:
-
Add to PATH: Ensure the npm global bin directory is in your PATH:
export PATH="$(npm config get prefix)/bin:$PATH"
-
Use npx: As an alternative, run without installing globally:
Permission Errors
On Linux/macOS, if you get permission errors during global installation:
sudo npm install -g @usebruno/cli
Or configure npm to use a different directory (recommended):
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
Next Steps
Running Tests
Learn how to run your API tests with the CLI
CLI Options
Explore all available command-line options