JSPM

  • Created
  • Published
  • Downloads 419
  • Score
    100M100P100Q103400F
  • License MIT

Universal test results collector for Jest, Jasmine, Mocha, Cypress, Playwright, and Vitest that sends results to Buddy Works API in real-time

Package Exports

  • @buddy-works/unit-tests/cypress
  • @buddy-works/unit-tests/jasmine
  • @buddy-works/unit-tests/jest
  • @buddy-works/unit-tests/mocha
  • @buddy-works/unit-tests/playwright
  • @buddy-works/unit-tests/vitest

Readme

@buddy-works/unit-tests

Universal test results collector that sends real-time test results from popular JavaScript testing frameworks directly to your Buddy Works unit testing dashboard. Zero configuration required - just install, add to your test config, and go.

Supported frameworks: Jest, Jasmine, Mocha, Cypress, Playwright, Vitest

Installation

npm install --save-dev @buddy-works/unit-tests

Setup

1. Get your token

In your Buddy Works workspace, go to the Unit Tests section and create a new folder. You'll receive a BUDDY_UT_TOKEN - set this as an environment variable in your CI/CD pipeline.

2. Add to your test configuration

Choose your testing framework and add the reporter:

Jest (jest.config.js):

module.exports = {
  reporters: ['default', '@buddy-works/unit-tests/jest'],
}

Jasmine - Add to helpers (__tests__/helpers/setup-reporter.js):

const buddyTestCollector = require('@buddy-works/unit-tests/jasmine').default

jasmine.getEnv().addReporter(buddyTestCollector)

Then reference it in jasmine.json:

{
  "helpers": ["helpers/setup-reporter.js"]
}

Mocha (.mocharc.js):

module.exports = {
  reporter: '@buddy-works/unit-tests/mocha',
}

Vitest (vitest.config.js):

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    reporters: ['default', '@buddy-works/unit-tests/vitest'],
  },
})

Playwright (playwright.config.js):

import { defineConfig } from '@playwright/test'

export default defineConfig({
  reporter: [['@buddy-works/unit-tests/playwright']],
})

Cypress (cypress.config.js):

const { defineConfig } = require('cypress')
const BuddyCypressReporter = require('./node_modules/@buddy-works/unit-tests/dist/reporters/cypress/index.js')

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

Note for Cypress: You must also install mocha as a dev dependency since the Cypress reporter requires it:

npm install --save-dev mocha

That's it! Your tests will now automatically send results to Buddy Works.

Note: These examples show configuration file setups. Some frameworks may support alternative configuration methods (command line options, package.json, etc.). Refer to your testing framework's official documentation for all available configuration options.

How It Works

The collector automatically detects your CI/CD environment and gathers all necessary metadata from your pipeline. It creates test sessions, tracks individual test results in real-time, and handles session cleanup automatically.

Supported CI/CD platforms:

  • Buddy Works - Full native support with automatic environment detection
  • GitHub Actions - Complete support with workflow integration
  • Other platforms - Can be configured manually with environment variables

Designed for CI/CD: While it can run locally, it's optimized for CI/CD pipelines where environment variables are automatically available.

Key Features

  • Zero configuration - Only requires BUDDY_UT_TOKEN
  • Real-time reporting - Test results sent as they complete
  • Automatic session management - Handles test session lifecycle
  • Universal support - Works with all major JavaScript testing frameworks
  • Multi-platform CI/CD support - Native support for Buddy Works and GitHub Actions
  • Smart environment detection - Automatically detects CI environment and configures accordingly

Development Testing

To run the example tests for development and testing purposes:

  1. Install dependencies:

    npm i
  2. Prepare the package for testing:

    npm run prepare:tests
  3. Follow individual test instructions: Each test framework has its own directory under examples/ with specific setup instructions. Check the README file in each individual test directory for framework-specific instructions.

    Available test frameworks:

    • examples/jest/ - Jest testing framework
    • examples/jasmine/ - Jasmine testing framework
    • examples/mocha/ - Mocha testing framework
    • examples/cypress/ - Cypress testing framework
    • examples/playwright/ - Playwright testing framework
    • examples/vitest/ - Vitest testing framework