GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bktest/test-collector-javascript at main · buildkite/bktest

Expand file tree

/

test-collector-javascript

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

test-collector-javascript

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
.buildkite
.buildkite
 
 
cypress
cypress
 
 
docs
docs
 
 
e2e
e2e
 
 
examples
examples
 
 
jasmine
jasmine
 
 
jest
jest
 
 
mocha
mocha
 
 
playwright
playwright
 
 
util
util
 
 
vitest
vitest
 
 
.gitignore
.gitignore
 
 
.node-version
.node-version
 
 
AGENTS.md
AGENTS.md
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
buildkite.yaml
buildkite.yaml
 
 
jest.config.js
jest.config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

README.md

Outline

Buildkite Collectors for JavaScript

Official Buildkite Test Engine collectors for JavaScript test frameworks ✨

⚒ Supported test frameworks: Jest, Jasmine, Mocha, Cypress, Playwright, Vitest, and more coming soon.

📦 Supported CI systems: Buildkite, GitHub Actions, CircleCI, and others via the BUILDKITE_ANALYTICS_* environment variables.

👉 Installing

  1. Create a test suite, and copy the API token that it gives you.

  2. Add the buildkite-test-collector package:

    # If you use npm:
    npm install --save-dev buildkite-test-collector
    
    # or, if you use yarn:
    yarn add --dev buildkite-test-collector
  3. Add the Buildkite test collector to your testing framework:

    Jest

    See a working Jest example.

    Update your Jest configuration:

    // jest.config.js
    
    // Send results to Test Engine
    reporters: [
      'default',
      'buildkite-test-collector/jest/reporter'
    ],
    
    // Enable column + line capture for Test Engine
    testLocationInResults: true

    Prefer BUILDKITE_ANALYTICS_TOKEN: jest --showConfig and config-dumping reporters can print reporter options.

    If you would like to pass in the API token using a custom environment variable, you can do so using the report options.

    // jest.config.js
    
    // Send results to Test Engine
    reporters: [
      "default",
      [
        "buildkite-test-collector/jest/reporter",
        { token: process.env.CUSTOM_ENV_VAR },
      ],
    ];

    Vitest

    See a working example for Vitest 5 or Vitest 4.

    Supports Vitest 1–5. Vitest 5 requires Node.js 22.12+; the reporter configuration below is unchanged when upgrading from Vitest 4.

    Update your Vitest configuration:

    // vitest.config.js OR vite.config.js
    
    
    test: {
    // Send results to Test Engine
      reporters: [
        'default',
        'buildkite-test-collector/vitest/reporter'
      ],
    
      // Enable column + line capture for Test Engine
      includeTaskLocation: true,
    }

    If you would like to pass in the API token using a custom environment variable, you can do so using the report options.

    // vitest.config.js OR vite.config.js
    
    
    test: {
    // Send results to Test Engine
      reporters: [
        'default',
        [
          "buildkite-test-collector/vitest/reporter",
          { token: process.env.CUSTOM_ENV_VAR },
        ],
      ],
    }

    Jasmine

    Add the Buildkite reporter to Jasmine:

    // SpecHelper.js
    var BuildkiteReporter = require("buildkite-test-collector/jasmine/reporter");
    var buildkiteReporter = new BuildkiteReporter();
    
    jasmine.getEnv().addReporter(buildkiteReporter);

    If you would like to pass in the API token using a custom environment variable, you can do so using the report options.

    // SpecHelper.js
    var buildkiteReporter = new BuildkiteReporter(undefined, {
      token: process.env.CUSTOM_ENV_VAR,
    });

    Mocha

    Install mocha-multi-reporters in your project (Mocha 12 needs 1.5.2 or later):

    npm install mocha-multi-reporters --save-dev
    

    and configure it to run your desired reporter and the Buildkite reporter

    // config.json
    {
      "reporterEnabled": "spec, buildkite-test-collector/mocha/reporter"
    }

    Now update your test script to use the buildkite reporter via mocha-multi-reporters:

      // package.json
      "scripts": {
        "test": "mocha --reporter mocha-multi-reporters --reporter-options configFile=config.json"
      },

    If you would like to pass in the API token using a custom environment variable, you can do so using the report options.

    Since the reporter options are passed in as a json file, we ask you to put the environment variable name as a string value in the config.json, which will be retrieved using dotenv in the mocha reporter.

    // config.json
    {
      "reporterEnabled": "spec, buildkite-test-collector/mocha/reporter",
      "buildkiteTestCollectorMochaReporterReporterOptions": {
        "token_name": "CUSTOM_ENV_VAR_NAME"
      }
    }

    Playwright

    See a working Playwright example.

    Update your Playwright configuration:

    // playwright.config.js
    
    // Send results to Test Engine
    reporter: [
      ['line'],
      ['buildkite-test-collector/playwright/reporter']
    ],

    Prefer BUILDKITE_ANALYTICS_TOKEN (or BUILDKITE_TESTS_OTLP_TOKEN for OpenTelemetry) so the credential stays out of your Playwright configuration. The collector omits its token option from Playwright's JSON report, but does not redact other credentials in your configuration or test output. Redaction failures warn that reports may contain credentials, but do not prevent uploads.

    If you would like to pass in the API token using a custom environment variable, you can do so using the report options.

    // playwright.config.js
    
    // Send results to Test Engine
    reporter: [
      ['line'],
      ['buildkite-test-collector/playwright/reporter', { token: process.env.CUSTOM_ENV_VAR },]
    ],

    If you would like to pass execution tags through to Test Engine, then you can use Playwright's tagging syntax as follows:

    test('has tags', { tag: ['@type:feature'] }, ...)
    

    This will be threaded through to Test Engine as an execution tag with key set to type and value set to feature.

    Cypress

    See a working Cypress example.

    Update your Cypress configuration:

     // cypress.config.js
    
     // Send results to Test Engine
    reporter: "buildkite-test-collector/cypress/reporter",

    If you would like to pass in the API token using a custom environment variable, you can do so using the reporterOptions.

    // cypress.config.js
    
    // Send results to Test Engine
    reporterOptions: {
     token_name: "CUSTOM_ENV_VAR_NAME"
    }
  4. Run your tests locally:

    env BUILDKITE_ANALYTICS_TOKEN=xyz npm test
  5. Add the BUILDKITE_ANALYTICS_TOKEN secret to your CI, push your changes to a branch, and open a pull request 🎉

    git checkout -b add-bk-test-engine
    git commit -am "Add Buildkite Test Engine"
    git push origin add-bk-test-engine

🔭 OpenTelemetry (experimental)

See a working OpenTelemetry example for Jest, Vitest, or Playwright.

Jest, Vitest and Playwright can also send results as OpenTelemetry traces, with HTTP calls, database queries and your own spans under each test in Jest and Vitest, and steps in Playwright. JSON uploads stay the default.

The OpenTelemetry guide covers setup, billing and limits.

📓 Notes

This jest collector uses the onRunComplete hook to report test results to the Buildkite API. This interferes with the --forceExit CLI option and interrupts the request that sends tests results, meaning that no data will be available for your test suite. It's recommended to use --detectOpenHandles to find any hanging process and clean them up and remove the use of --forceExit.

🔍 Debugging

To enable debugging output, set the BUILDKITE_ANALYTICS_DEBUG_ENABLED environment variable to true.

🔜 Roadmap

See the GitHub 'enhancement' issues for planned features. Pull requests are always welcome, and we’ll give you feedback and guidance if you choose to contribute 💚

⚒ Developing

After cloning the repository, install the dependencies:

npm install

And run the tests:

npm test

Useful resources for developing collectors include the Buildkite Test Engine docs and the RSpec and Minitest collectors.

👩‍💻 Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/buildkite/bktest/issues

🚀 Releasing

See the monorepo's collector release guide.

📜 License

The package is available as open source under the terms of the MIT License.

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.