Skip to content

Commit 277f82f

Browse files
authored
Include pretty formatter with package (#2592)
1 parent c5eb896 commit 277f82f

File tree

10 files changed

+88
-73
lines changed

10 files changed

+88
-73
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) on how to contribute to Cucumber.
99

1010
## [Unreleased]
11+
### Added
12+
- Include updated pretty formatter ([#2592](https://github.com/cucumber/cucumber-js/pull/2592))
1113

1214
## [12.0.0] - 2025-07-13
1315
### Added

dependency-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ignoreErrors:
2323
unused:
2424
- '@cucumber/compatibility-kit' # files dynamically loaded in cck test, not required
2525
- '@cucumber/junit-xml-formatter' # formatter dynamically imported at runtime
26+
- '@cucumber/pretty-formatter' # formatter dynamically imported at runtime
2627
- '@eslint/compat' # used by eslint
2728
- '@eslint/eslintrc' # used by eslint
2829
- '@eslint/js' # used by eslint

docs/formatters.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,16 @@ Many formatters, including the built-in ones, support some configuration via opt
3434

3535
This option is repeatable, so you can use it multiple times and the objects will be merged with the later ones taking precedence.
3636

37-
Some options offered by built-in formatters:
37+
Some common options supported by built-in formatters:
3838

3939
- `colorsEnabled` - [see below](#colored-output)
4040
- `printAttachments` - if set to `false`, attachments won't be part of progress bars and summary reports
4141

42+
Some formatters have options that are only applicable to them. These options will be under a key that matches the formatter name, like this:
43+
44+
- In a configuration file `{ formatOptions: { pretty: { featuresAndRules : false } }`
45+
- On the CLI `cucumber-js --format-options '{"pretty":{"featuresAndRules":false}}'`
46+
4247
## Colored output
4348

4449
Many formatters, including the built-in ones, emit some colored output. By default, Cucumber will automatically detect the colors support of the output stream and decide whether to emit colors accordingly. This check comes via the [supports-colors](https://github.com/chalk/supports-color) library and is pretty comprehensive, including awareness of commonly-used operating systems and CI platforms that represent edge cases.
@@ -75,7 +80,19 @@ Similar to the Progress Formatter, but provides a real-time updating progress ba
7580

7681
![](./images/progress_bar_green.gif)
7782

78-
*Note: the Progress Bar Formatter will only work with a TTY terminal (and not, for example, a file stream).*
83+
### `pretty`
84+
85+
ℹ️ Added in v12.1.0
86+
ℹ️ Can be installed and referenced as `@cucumber/pretty-formatter` from v11.1.0
87+
88+
Writes a rich report of the scenario and example execution as it happens.
89+
90+
![](./images/pretty.png)
91+
92+
Options specific to this formatter (under the `pretty` key):
93+
94+
- `featuresAndRules` - whether to include headings for Features and Rules (defaults to `true`)
95+
- `theme` - control over the styling of various elements (see [documentation](https://github.com/cucumber/pretty-formatter/blob/main/javascript/README.md#themes))
7996

8097
### `html`
8198

@@ -120,7 +137,7 @@ Outputs details of the test run in the legacy JSON format.
120137

121138
The JUnit formatter produces an XML-based report in the standard(ish) [JUnit format](https://github.com/junit-team/junit5/blob/43638eb6a870e0d6c49224053dfeb39dcf0ef33f/platform-tests/src/test/resources/jenkins-junit.xsd). This is most commonly useful for having your CI platform pick up your tests results and factor them into its reporting. Consult your CI platform's docs for where exactly you should output this report to and what the filename should be.
122139

123-
Options specific to this formatter:
140+
Options specific to this formatter (under the `junit` key):
124141

125142
- `suiteName` - value to go in the `name` attribute of the `testsuite` element in the output (defaults to `cucumber-js`)
126143

docs/images/pretty.png

165 KB
Loading

package-lock.json

Lines changed: 56 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
},
259259
"devDependencies": {
260260
"@cucumber/compatibility-kit": "18.0.3",
261+
"@cucumber/pretty-formatter": "^2.0.0",
261262
"@cucumber/query": "13.5.0",
262263
"@eslint/compat": "^1.3.0",
263264
"@eslint/eslintrc": "^3.3.1",
@@ -294,7 +295,7 @@
294295
"eslint": "^9.29.0",
295296
"eslint-plugin-import": "^2.31.0",
296297
"eslint-plugin-n": "^17.20.0",
297-
"eslint-plugin-unicorn": "^59.0.1",
298+
"eslint-plugin-unicorn": "^57.0.0",
298299
"express": "^5.0.0",
299300
"fs-extra": "10.1.0",
300301
"genversion": "3.2.0",

src/api/formatters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export async function initializeFormatters({
7474
await pluginManager.initFormatter(
7575
implementation,
7676
configuration.options,
77+
stream,
7778
stream.write.bind(stream),
7879
directory
7980
)

src/formatter/builtin/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const builtin = {
1414
// new plugin-based formatters
1515
html: htmlFormatter,
1616
junit: '@cucumber/junit-xml-formatter',
17+
pretty: '@cucumber/pretty-formatter',
1718
message: messageFormatter,
1819
// legacy class-based formatters
1920
json: JsonFormatter,
@@ -32,6 +33,8 @@ export const documentation = {
3233
// new plugin-based formatters
3334
html: 'Outputs a HTML report',
3435
junit: 'Produces a JUnit XML report',
36+
pretty:
37+
'Writes a rich report of the scenario and example execution as it happens',
3538
message: 'Emits Cucumber messages in newline-delimited JSON',
3639
// legacy class-based formatters
3740
json: JsonFormatter.documentation,

src/plugin/plugin_manager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class PluginManager {
3535
async initFormatter<OptionsType>(
3636
plugin: FormatterPlugin<OptionsType>,
3737
options: OptionsType,
38+
stream: NodeJS.WritableStream,
3839
write: (buffer: string | Uint8Array) => void,
3940
directory?: string
4041
) {
@@ -44,6 +45,7 @@ export class PluginManager {
4445
? ((options as any)[plugin.optionsKey] ?? ({} as OptionsType))
4546
: options,
4647
logger: this.environment.logger,
48+
stream,
4749
write,
4850
directory,
4951
})

src/plugin/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export interface FormatterPluginContext<OptionsType> {
7171
on: (key: 'message', handler: (value: Envelope) => void) => void
7272
options: OptionsType
7373
logger: ILogger
74+
stream: NodeJS.WritableStream
7475
write: (buffer: string | Uint8Array) => void
7576
directory?: string
7677
}

0 commit comments

Comments
 (0)