bruno icon indicating copy to clipboard operation
bruno copied to clipboard

More Flexibility and Extensibility for the Bruno CLI

Open joeng03 opened this issue 6 months ago • 0 comments

I have checked the following:

  • [X] I've searched existing issues and found nothing related to my issue.

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:

  • [ ] 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.

  • [ ] 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). This feature would allow users to leverage existing information, such as test results and environment variables, for post-processing tasks. Currently, the workaround involves running the tests, outputting a JSON file, and then executing a separate script to process the results, which is cumbersome and inefficient. Moreover, since the CLI calls process.exit() immediately when there are failed tests, it is not possible to run asynchronous functions(such as sending alerts to an API endpoint) before the process exits.

  • [ ] Environment Variables as Objects: Allow users to pass environment variables as an object, instead of string. This improvement would facilitate calling the handler() function from @usebruno/cli/src/commands/run and passing sensitive information, such as credentials, securely. This enhancement addresses #2015.

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
});

joeng03 avatar Aug 04 '24 01:08 joeng03