-
-
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.
- Loading branch information
1 parent
5ce3718
commit 358abbb
Showing
18 changed files
with
226 additions
and
133 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
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 |
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,31 @@ | ||
import path from 'node:path' | ||
import { Writable } from 'node:stream' | ||
import { mkdirp } from 'mkdirp' | ||
import fs from 'mz/fs' | ||
import { ILogger } from '../logger' | ||
|
||
export async function createStream( | ||
target: string, | ||
onStreamError: () => void, | ||
cwd: string, | ||
logger: ILogger | ||
): Promise<Writable> { | ||
const absoluteTarget = path.resolve(cwd, target) | ||
|
||
try { | ||
await mkdirp(path.dirname(absoluteTarget)) | ||
} catch (error) { | ||
logger.warn('Failed to ensure directory for formatter target exists') | ||
} | ||
|
||
const stream: Writable = fs.createWriteStream(null, { | ||
fd: await fs.open(absoluteTarget, 'w'), | ||
}) | ||
|
||
stream.on('error', (error: Error) => { | ||
logger.error(error.message) | ||
onStreamError() | ||
}) | ||
|
||
return stream | ||
} |
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
Oops, something went wrong.