-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add formatter plugins and start reimplementing builtins (#2400)
- Loading branch information
1 parent
6dae044
commit b02a90a
Showing
29 changed files
with
372 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { promisify } from 'node:util' | ||
import { finished } from 'node:stream' | ||
import CucumberHtmlStream from '@cucumber/html-formatter' | ||
import resolvePkg from 'resolve-pkg' | ||
import { FormatterPlugin } from '../../plugin' | ||
|
||
export default { | ||
type: 'formatter', | ||
formatter({ on, write }) { | ||
const htmlStream = new CucumberHtmlStream( | ||
resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) + | ||
'/dist/main.css', | ||
resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) + | ||
'/dist/main.js' | ||
) | ||
on('message', (message) => htmlStream.write(message)) | ||
htmlStream.on('data', (chunk) => write(chunk)) | ||
|
||
return async () => { | ||
htmlStream.end() | ||
await promisify(finished)(htmlStream) | ||
} | ||
}, | ||
documentation: 'Outputs a HTML report', | ||
} satisfies FormatterPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { FormatterImplementation } from '../index' | ||
import JsonFormatter from '../json_formatter' | ||
import ProgressFormatter from '../progress_formatter' | ||
import ProgressBarFormatter from '../progress_bar_formatter' | ||
import RerunFormatter from '../rerun_formatter' | ||
import SnippetsFormatter from '../snippets_formatter' | ||
import SummaryFormatter from '../summary_formatter' | ||
import UsageFormatter from '../usage_formatter' | ||
import UsageJsonFormatter from '../usage_json_formatter' | ||
import JunitFormatter from '../junit_formatter' | ||
import messageFormatter from './message' | ||
import htmlFormatter from './html' | ||
|
||
const builtin: Record<string, FormatterImplementation> = { | ||
// new plugin-based formatters | ||
html: htmlFormatter, | ||
message: messageFormatter, | ||
// legacy class-based formatters | ||
json: JsonFormatter, | ||
progress: ProgressFormatter, | ||
'progress-bar': ProgressBarFormatter, | ||
rerun: RerunFormatter, | ||
snippets: SnippetsFormatter, | ||
summary: SummaryFormatter, | ||
usage: UsageFormatter, | ||
'usage-json': UsageJsonFormatter, | ||
junit: JunitFormatter, | ||
} | ||
|
||
export default builtin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { FormatterPlugin } from '../../plugin' | ||
|
||
export default { | ||
type: 'formatter', | ||
formatter({ on, write }) { | ||
on('message', (message) => write(JSON.stringify(message) + '\n')) | ||
}, | ||
documentation: 'Emits Cucumber messages in NDJSON format', | ||
} satisfies FormatterPlugin |
Oops, something went wrong.