Universal test results collector for Jest, Jasmine, Mocha, Cypress, Playwright, and Vitest that sends results to Buddy Works API in real-time.
- 🚀 Real-time reporting - Test results are sent immediately after each test completion
- 🔧 Multi-framework support - Works with Jest, Jasmine, Mocha, Cypress, Playwright, and Vitest
- 📊 Buddy Works integration - Direct integration with Buddy Works Unit Tests API
- ⚡ Non-blocking - Won't slow down your test execution
- 🛡️ Error resilience - API failures won't break your test runs
- 🔍 Debug support - Built-in logging for troubleshooting
npm install js-tests-results-collector --save-dev
The Buddy Works API uses OAuth2 authentication with Bearer tokens. You need to generate an access token in your Buddy Works workspace settings.
To get an access token:
- Go to your Buddy Works workspace
- Navigate to Workspace Settings → Developer API
- Enable the API if not already enabled
- Generate or use an existing Personal Access Token
Buddy Works has different API endpoints depending on your region and installation type:
-
US Region (default):
https://api.buddy.works
-
EU Region:
https://api.eu.buddy.works
-
On-premise:
https://your-domain.buddy.works
Set the appropriate endpoint using the BUDDY_API_BASE_URL
environment variable.
Set the following environment variables:
# Required
BUDDY_WORKSPACE_DOMAIN=your-domain
BUDDY_PROJECT_NAME=your-project
BUDDY_FOLDER_ID=123 # must be an integer
BUDDY_ACCESS_TOKEN=your-oauth-access-token
# API Endpoint (choose based on your region/installation)
BUDDY_API_BASE_URL=https://api.buddy.works # US region (default)
# BUDDY_API_BASE_URL=https://api.eu.buddy.works # EU region
# BUDDY_API_BASE_URL=https://your-domain.buddy.works # On-premise installation
# Optional
BUDDY_RUN_BRANCH=main # defaults to current git branch
BUDDY_REF_TYPE=BRANCH # defaults to BRANCH
BUDDY_RUN_COMMIT=abc123 # defaults to current git commit
BUDDY_RUN_PRE_COMMIT=def456 # defaults to current git commit
BUDDY_RUN_HASH=build-123 # optional build identifier
BUDDY_RUN_URL=https://example.com/builds/123 # optional build URL
BUDDY_SOURCE=API # defaults to API
BUDDY_DEBUG=true # enable debug logging
Add the reporter to your Jest configuration:
jest.config.js:
module.exports = {
reporters: [
'default',
'js-tests-results-collector/jest'
]
};
Or in package.json:
{
"jest": {
"reporters": [
"default",
"js-tests-results-collector/jest"
]
}
}
Use the reporter with the --reporter
flag:
mocha --reporter js-tests-results-collector/mocha test/**/*.js
Or in package.json:
{
"scripts": {
"test": "mocha --reporter js-tests-results-collector/mocha test/**/*.js"
}
}
Add the reporter to your Jasmine configuration:
spec/support/jasmine.json:
{
"spec_dir": "spec",
"spec_files": ["**/*[sS]pec.js"],
"helpers": [
"helpers/**/*.js",
"js-tests-results-collector/jasmine"
]
}
Add the reporter to your Cypress configuration:
cypress.config.js:
const { defineConfig } = require('cypress');
module.exports = defineConfig({
e2e: {
reporter: 'js-tests-results-collector/cypress',
// ... other config
},
});
Add the reporter to your Playwright configuration:
playwright.config.js:
module.exports = {
reporter: [
['list'],
['js-tests-results-collector/playwright']
],
// ... other config
};
Add the reporter to your Vitest configuration:
vitest.config.js:
export default {
test: {
reporters: [
'default',
'js-tests-results-collector/vitest'
]
}
};
Or in package.json:
{
"scripts": {
"test": "vitest run --reporter=default --reporter=js-tests-results-collector/vitest"
}
}
- Session Creation: When tests start, a session is created via Buddy Works API
- Real-time Reporting: Each test result is sent immediately after completion
- Result Mapping: Framework-specific results are mapped to Buddy's format
- Error Handling: API failures are logged but don't interrupt test execution
The collector integrates with Buddy Works Unit Tests API:
POST /workspaces/{domain}/projects/{projectName}/unit-tests/folders/{folderId}/sessions
PUT /workspaces/{domain}/projects/{projectName}/unit-tests/folders/{folderId}/sessions/{sessionId}/cases
Test results are mapped to the following format:
{
"name": "Test case name",
"suite_name": "Test suite name",
"suite_id": "unique-suite-id",
"classname": "test.file.path",
"status": "PASSED|FAILED|SKIPPED|ERROR",
"time": 1.234,
"data": "Error message or additional data"
}
Enable debug logging to troubleshoot issues:
BUDDY_DEBUG=true npm test
This will output detailed logs about:
- Session creation
- Test result submissions
- API responses
- Error details
Check the examples/
directory for complete configuration examples:
-
examples/jest-example/
- Jest configuration -
examples/mocha-example/
- Mocha configuration -
examples/jasmine-example/
- Jasmine configuration -
examples/cypress-example/
- Cypress configuration -
examples/playwright-example/
- Playwright configuration -
examples/vitest-example/
- Vitest configuration
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
For issues and questions:
- Check the debug logs with
BUDDY_DEBUG=true
- Review the examples in the
examples/
directory - Open an issue on GitHub
- Initial release
- Support for Jest, Jasmine, Mocha, Cypress, Playwright, and Vitest
- Real-time test result reporting
- Buddy Works API integration