CucumberJS
The official Flakiness.io reporter for CucumberJS. The open source implementation is available at github.com/flakiness/cucumberjs.
A custom CucumberJS formatter that generates Flakiness Reports from your Cucumber test runs. The formatter automatically converts CucumberJS test results into the standardized Flakiness JSON format, preserving complete Gherkin structure, test outcomes, and environment information.
Quick Start
Section titled “Quick Start”-
Install the Flakiness.io CucumberJS formatter:
Terminal window npm install -D @flakiness/cucumberjs -
Add the formatter to your
cucumber.mjsconfiguration file:cucumber.mjs export default {format: ['progress',['@flakiness/cucumberjs', '.flakiness/cucumber-formatter.log'],],formatOptions: {flakinessProject: 'my-org/my-project',},}; -
Run your tests. The report will be automatically generated in the
./flakiness-reportfolder:Terminal window npx cucumber-js -
View the interactive report:
Terminal window npx flakiness show ./flakiness-report
Supported Gherkin Features
Section titled “Supported Gherkin Features”- Scenarios & Scenario Outlines (with multiple Examples blocks)
- Rules
- Tags & tag inheritance (Feature → Rule → Scenario → Examples)
- Steps (Given/When/Then with keyword prefix)
- Data Tables
- Before & After Hooks (named and unnamed)
- Feature, Rule, and Scenario descriptions
- Attachments (
this.attach()andthis.log()) - Retries (
--retry) - Parallel execution (
--parallel) - All statuses: passed, failed, pending, undefined, ambiguous, skipped
CI/CD Integration
Section titled “CI/CD Integration”Reports are automatically uploaded to Flakiness.io at the end of each test run when authentication is configured. If no credentials are present, the report is still generated locally and can be uploaded manually later.
When uploading succeeds, you’ll see a confirmation in your terminal:
[flakiness.io] ✓ Uploaded as https://flakiness.io/my-org/my-project/run/42| Upload Method | Status | Guide |
|---|---|---|
| GitHub OIDC | Supported | GitHub Actions |
| Access Token | Supported | GitHub Actions |
| Other CI | Supported | Other CI Providers |
Configuration
Section titled “Configuration”All options are passed via CucumberJS’s formatOptions in your configuration file.
flakinessProject?: string
Section titled “flakinessProject?: string”The Flakiness.io project identifier in org/project format. Required for GitHub OIDC authentication. Defaults to the FLAKINESS_PROJECT environment variable.
formatOptions: { flakinessProject: 'my-org/my-project',}endpoint?: string
Section titled “endpoint?: string”Custom Flakiness.io endpoint URL for uploading reports. Defaults to the FLAKINESS_ENDPOINT environment variable, or https://flakiness.io if not set.
Use this option to point to a custom or self-hosted Flakiness.io instance.
formatOptions: { endpoint: 'https://custom.flakiness.io',}token?: string
Section titled “token?: string”Access token for authenticating with Flakiness.io when uploading reports. Defaults to the FLAKINESS_ACCESS_TOKEN environment variable.
If no token is provided, the formatter will attempt GitHub OIDC when flakinessProject is set. If neither is available, the report is generated locally without uploading.
formatOptions: { token: 'your-access-token',}outputFolder?: string
Section titled “outputFolder?: string”Directory path where the Flakiness report will be written. Defaults to flakiness-report in the current working directory, or the FLAKINESS_OUTPUT_DIR environment variable if set.
formatOptions: { outputFolder: './test-results/flakiness',}disableUpload?: boolean
Section titled “disableUpload?: boolean”When set to true, prevents uploading the report to Flakiness.io. The report is still generated locally. Can also be controlled via the FLAKINESS_DISABLE_UPLOAD environment variable.
formatOptions: { disableUpload: true,}Environment Variables
Section titled “Environment Variables”The formatter respects the following environment variables:
FLAKINESS_ACCESS_TOKEN: Access token for Flakiness.io uploads (equivalent totokenoption)FLAKINESS_PROJECT: Flakiness.io project inorgSlug/projectSlugformat (equivalent toflakinessProjectoption)FLAKINESS_ENDPOINT: Custom Flakiness.io endpoint URL (equivalent toendpointoption)FLAKINESS_OUTPUT_DIR: Output directory for reports (equivalent tooutputFolderoption)FLAKINESS_DISABLE_UPLOAD: Disable automatic upload (equivalent todisableUploadoption)FK_ENV_*: Custom environment variables prefixed withFK_ENV_are automatically included in the environment’smetadata. The prefix is stripped and the key is converted to lowercase.
Example:
export FK_ENV_DEPLOYMENT=stagingexport FK_ENV_REGION=us-east-1This will result in the environment containing:
{ "metadata": { "deployment": "staging", "region": "us-east-1" }}Flakiness.io platform will create a dedicated history for tests executed in each unique environment. This means tests run with FK_ENV_DEPLOYMENT=staging will have a separate timeline from tests run with FK_ENV_DEPLOYMENT=production, allowing you to track flakiness patterns specific to each deployment environment.
Example Configuration
Section titled “Example Configuration”Here’s a complete example with all options:
export default { format: [ 'progress', ['@flakiness/cucumberjs', '.flakiness/cucumber-formatter.log'], ], formatOptions: { flakinessProject: 'my-org/my-project', endpoint: process.env.FLAKINESS_ENDPOINT, token: process.env.FLAKINESS_ACCESS_TOKEN, outputFolder: './flakiness-report', disableUpload: false, },};Requirements
Section titled “Requirements”@cucumber/cucumber12.0 or higher- Node.js project with a git repository (for commit information)
License & Source Code
Section titled “License & Source Code”The source code is available under MIT license at https://github.com/flakiness/cucumberjs