Add the Buildkite test collector to your testing framework:
Jest
Update your Jest configuration:
reporters: [
'default',
'buildkite-test-collector/jest/reporter'
],
testLocationInResults: true
If you would like to pass in the API token using a custom environment variable, you can do so using the report options.
reporters: [
"default",
[
"buildkite-test-collector/jest/reporter",
{ token: process.env.CUSTOM_ENV_VAR },
],
];
Jasmine
Add the Buildkite reporter to Jasmine:
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.
var buildkiteReporter = new BuildkiteReporter(undefined, {
token: process.env.CUSTOM_ENV_VAR,
});
Mocha
Install mocha-multi-reporters in your project:
npm install mocha-multi-reporters --save-dev
and configure it to run your desired reporter and the Buildkite reporter
{
"reporterEnabled": "spec, buildkite-test-collector/mocha/reporter"
}
Now update your test script to use the buildkite reporter via mocha-multi-reporters:
"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.
{
"reporterEnabled": "spec, buildkite-test-collector/mocha/reporter",
"buildkiteTestCollectorMochaReporterReporterOptions": {
"token_name": "CUSTOM_ENV_VAR_NAME"
}
}
Playwright
Update your Playwright configuration:
reporter: [
['line'],
['buildkite-test-collector/playwright/reporter']
],
If you would like to pass in the API token using a custom environment variable, you can do so using the report options.
reporter: [
['line'],
['buildkite-test-collector/playwright/reporter', { token: process.env.CUSTOM_ENV_VAR },]
],
Cypress
Update your Cypress configuration:
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.
reporterOptions: {
token_name: "CUSTOM_ENV_VAR_NAME"
}