usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.68k stars 1.28k forks source link

More Flexibility and Extensibility for the Bruno CLI #2751

Open joeng03 opened 3 months ago

joeng03 commented 3 months ago

I have checked the following:

Describe the feature you want to add

When working with Bruno on a company project, I identified several areas where the Bruno CLI could benefit from increased flexibility and extensibility. Here are the features I propose:

Mockups or Images of the feature

import { handler } from "@usebruno/cli/src/commands/run";
// Call the handler function with the necessary parameters
handler({
    format: ["json", "html"],
    postProcess: <JS_FUNCTION>,
    env: <ENVIRONMENT_VARIABLES_IN_A_JS_OBJECT>
    // Other necessary options
});
csvtuda commented 1 week ago

Multiple Output Formats: Allow the --format option to accept an array of formats (e.g., html, json, junit) instead of just one. This enhancement would enable generating reports in different formats within a single run. Currently, to obtain reports in multiple formats, we have to rerun the tests for each format, which can lead to inconsistent results due to test variability.

As of v1.29.0, it is possible to generate multiple reports at the same time:

npx bru run request.bru --reporter-json results.json --reporter-junit results.xml --reporter-html results.html

Post-Test Script Execution: Introduce the ability to pass in a script or function to run after the tests complete, or conditionally execute if certain criteria are met (e.g., if some test cases fail).

I second this. Having the ability to configure custom reporters would be a great addition. For example, in my current project, we need to upload Bruno's test results to Xray. We wrote a small utility script to convert Bruno's JSON report into the format Xray expects. But I think it would be better if we released our script as an npm package so that other people could use it by simply importing it as a custom reporter.