Setup & Reporters

Creating a Suite in Buddy Project

To get started with Unit Tests, you need to create a test suite in your Buddy project:

  1. Navigate to project settings
  2. Select the Test Suites tab
  3. Click +, to add a new suite

Image loading...Project Settings - Empty Test Suites Section

  1. Add a new suite form:
    • Enter the suite name (e.g., "My Unit Test")
    • ID is automatically generated based on the suite name (e.g., my-unit-test). The suite ID can be used as a reference in YAML, variables, and scripts.
    • Click Add suite

Image loading...Project Settings Test Suites

After creating a suite, you will see a configuration interface with tabs for different testing frameworks: Jest, Jasmine, Mocha, Cypress, Playwright, Vitest, and More (which includes JUnit XML and NUnit options).

Each framework tab contains step-by-step instructions:

  1. Install unit tests package — the command for installing the package, including information about requirements
  2. Set token — the command for exporting the environment variable with the suite’s unique token
  3. Run tests with Buddy reporter — the command for running tests with the Buddy reporter

Installing the Package

Install Buddy Unit Tests package:

bash
npm install --save-dev @buddy-works/unit-tests $
Hint
Node.js version 20 or higher is required in your project.

Setting the Token

Set the BUDDY_UT_TOKEN environment variable using your suite’s token:

bash
export BUDDY_UT_TOKEN=<YOUR_TOKEN> $

You will find the token in the suite settings

Running Your First Test

After installing the package and setting the token, you can run the tests from the terminal. For example, with Playwright:

bash
npm install --save-dev @buddy-works/unit-tests npx playwright install export BUDDY_UT_TOKEN=<YOUR_TOKEN> npx playwright test --reporter=@buddy-works/unit-tests/playwright $$$$

After running the tests, the interface automatically switches to the Sessions tab, where you can see live test results as they execute. The session will complete once all tests have finished.

To use Unit Tests in a Buddy pipeline, see the Pipeline Integration section. You can find detailed information about viewing results in the Results & Analytics section.

Suite Settings

Image loading...Unit Tests Settings

The Settings tab allows you to configure your test suite.

  • SUITE NAME: Edit the display name of your suite.
  • SUITE ID: Display or modify the suite ID (used in YAML, variables and scripts).
  • SUITE TOKEN: View your suite’s unique token. The Regenerate button allows you to create a new token.
  • ERROR PATTERN: Adjust the error notification pattern using the placeholders:

    default
    #### Failure Message {{testcase.failure.message}} #### StackTrace {{testcase.failure}}
  • TIMEOUT: Set the maximum duration of a test session. Default is 60 seconds.
  • SLOW THRESHOLD: Define the slow tests treshold. Default is 500ms.

Unit Tests CLI

The CLI tab provides quick access to configuration commands for all supported frameworks. You can switch between the framework tabs (Jest, Jasmine, Mocha, Cypress, Playwright, Vitest, JUnit XML, NUnit) to view the appropriate installation commands, token configuration, and test execution instructions.

For frameworks that use JUnit XML or NUnit, the CLI tab also provides options for:

  • Operating system selection: Windows, macOS, Linux, Linux ARM
  • Installation methods: Chocolatey, Download or npm
  • CLI install command: e.g., sudo npm i -g bdy
  • Upload command: bdy tests upload --format junit-xml TestResults/TestResult.xml

Image loading...Unit Tests CLI Tab

Built-in Live Reporters

Below you will find detailed configuration instructions for each supported testing framework:

Jest

bash
npx jest --reporters=default --reporters=@buddy-works/unit-tests/jest $

Jasmine

bash
npx jasmine --reporter=@buddy-works/unit-tests/jasmine $

Mocha

bash
npx mocha --reporter @buddy-works/unit-tests/mocha $

Cypress

First, install both the unit tests package and Mocha (required for Cypress):

bash
npm install --save-dev @buddy-works/unit-tests mocha $

Then configure your cypress.config.js:

javascript
const { defineConfig } = require('cypress') const BuddyCypressReporter = require('@buddy-works/unit-tests/cypress') module.exports = defineConfig({ e2e: { reporter: '@buddy-works/unit-tests/dist/reporters/cypress/index.js', setupNodeEvents(on) { on('after:run', BuddyCypressReporter.closeSession) }, }, })

And run tests with:

bash
npx cypress run $

Playwright

bash
npx playwright test --reporter=@buddy-works/unit-tests/playwright $

Image loading...Configure Unit Tests for Playwright

Vitest

bash
npx vitest --reporter=default --reporter=@buddy-works/unit-tests/vitest $

Other Frameworks

For frameworks that don’t have a built-in reporter, you can use the JUnit XML or NUnit format together with the Buddy CLI.

In the CLI tab you can specify operating system and installation method.

  • Windows: Chocolatey, Download lub npm
  • macOS: Homebrew, Download lub npm
  • Linux / Linux ARM: APT, Download lub npm

After installing the Buddy CLI and setting the token, you can upload the test results as follows:

JUnit XML

bash
bdy tests upload --format junit-xml reports/*.xml $

Image loading...Configure Unit Tests - JUnit XML

NUnit

bash
bdy tests upload --format junit-xml TestResults/TestResult.xml $

Image loading...Configure Unit Tests - NUnit

Alternatively, you can use the Buddy API to build your own live reporter.

Reporting from Anywhere

You can send test results from:

  • Buddy pipeline - add a test action to your pipeline
  • GitHub Actions - use Buddy reporters or CLI
  • CircleCI i innych platform CI - integrate via Buddy CLI or API
  • Terminal - run tests locally and display the results in Buddy

Last modified on Dec 5, 2025